提取部分电子邮件地址

鉴于:

thread-reply+xxxxxxxxxxxx@mysite.com

我怎样才能得到-+之间的内容,在这种情况下是reply

我尝试着:

 [/\-(.*?)+/,1] 

你需要逃避+

 [/\-(.*?)\+/,1] 

以下是应该工作的模式的一般正则表达式语法:

 ^([^-]*)-([^+]*)\+.*$ 

Rubular说它有效 。 看看比赛截图。

说明:

 ^ // the start of the input ([^-]*) // the 'thread' part - // a literal '-' ([^+]*) // the 'reply' part \+ // a literal '+' .* // the rest of the input $ // the end