Extracting part of email address
Given:
thread-reply+xxxxxxxxxxxx@mysite.com
How do I go about getting what's in between the -
and the 开发者_如何学JAVA+
, in this case being reply
?
I'm trying:
[/\-(.*?)+/,1]
You need to escape +
:
[/\-(.*?)\+/,1]
The following is a general regex syntax for a pattern that should work:
^([^-]*)-([^+]*)\+.*$
Rubular says it works. Look at the match captures.
Explanation:
^ // the start of the input
([^-]*) // the 'thread' part
- // a literal '-'
([^+]*) // the 'reply' part
\+ // a literal '+'
.* // the rest of the input
$ // the end
精彩评论