开发者

Troubles with Regex matching an optional string (powershell)

Say I have the following items (line numbers for reference only):

1: ER (1000) Attac开发者_开发百科hments
2: ER (1000) Attachments (1)
3: ER (125) Attachments
4: ER (1) Attachments

I need to match all of the above. Here's the regex I'm using:

ER \([0-9]*\) Attachments

This returns numbers 1,3, and 4. It does not match #2.

ER \([0-9]*\) Attachments.+

does not work either.

Any ideas?


You could try

ER \([0-9]*\) Attachments.*$

This works for me.

EDIT

This also works for me:

^.*?\(\d+\).*$
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜