开发者

Regex help matching 5 lines

开发者 https://www.devze.com 2023-01-27 09:36 出处:网络
I\'m looking for some help from a regex guru, here\'s what I want to be able to match and remove using ruby/rails:

I'm looking for some help from a regex guru, here's what I want to be able to match and remove using ruby/rails:

-----Original Message-----
From: STATIC on behalf of STATIC
Sent: Thu 11/25/2010 11:17 AM
To: Random, Random
Subject: Ra开发者_StackOverflow社区ndom replied to the comment

is it possible with regex to match these 5 lines with one Regex? Here's what I've been trying, without luck:

gsub(/-----Original Message-----/n.* From.*/n Sent.*/n To.*/n Subject.*/, '')

Thanks for the help


You need to reverse the slashes for the newlines and remove the extra space after each newline.

-----Original Message-----\n.*From.*\nSent.*\nTo.*\nSubject.*

http://rubular.com/r/z9NwUT7FWJ

0

精彩评论

暂无评论...
验证码 换一张
取 消