开发者

Question on regular expression

I have a string of the type

"X-Request-Recipients: assignee:tammalac; cat:an开发者_如何学Cgub; cat:bashas; cat:bhattacs; sev:nukalas; sev:abc@somewhere; sub-all:majumdaa;sub-all:mayakunp; sub-all:srinivay; sub-all:tammalac; "

Now question what is the regular expression expression to extract any number of strings after : and before ;.

P.S. I would be accessing this from a perl script.


The regex that matches these parts would be

\w:([^;]+);

or, more specifically

(?:username|subscriber):([^;]+);

Use the contents of group 1 as the result.

\w:      # a word character and a colon
(        # begin group 1
  [^;]+  #   any character except a semi-colon, at least one
)        # end group 1
;        # a semi-colon


Try this regular expression:

:([^;]+)

Using your sample text this will work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜