开发者

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜