Is this possible?
From this string:
string = "lsdfh892pr23hr4342pr3j4r\n\nwww.foobar.com•\nyahoogooglebing"
I want to extract "www.foobar.com"
.
And, from this one:
string = "lsdfh892pr23hr4342pr3j4r\n\ninfo@google.com•\nyahoogooglebing"
I want to extract "info@google.com"
.
我不知道Ruby的语法,但是这个正则表达式应该工作:
/\n\n([^•]*)•/
I wouldn't bother with a regular expression:
string = "lsdfh892pr23hr4342pr3j4r\n\nwww.foobar.com•\nyahoogooglebing"
string.split("\n")[2][0..-2]
=> "www.foobar.com"
string = "lsdfh892pr23hr4342pr3j4r\n\ninfo@google.com•\nyahoogooglebing"
string.split("\n")[2][0..-2]
=> "info@google.com"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.