开发者

How to write java.Replace regex expression?

I am trying to write a regex expression to replace the following in a space delimited file

The file has:

WORD WORD C F F ANOTHER WORD

ANOTHER WORD D H F ANOTHER ANOTHER

I am trying to get the expression to capture开发者_如何学JAVA the LAST F between F F and H F.

I wrote this expression but it doesn't process correctly in JAVA.

\\(\\(?:[a-z][a-z0-9_]*\\)\\)(\\s+)(F)(\\s+)

Can anyone help out? I'm trying to use this with String.ReplaceALL.

Thanks.


((?:[a-z][a-z0-9_]+))(\\s+)(F)(\\s+)

This is the translation of what you have that is a valid regex.


How about this one :

\\b(F)\\b(?!\\s+\\bF\\b)

looking for standalone F not followed by another standalone F


This one matches such strings. But how do you replace?

"^.* F ([^ ]*|[ F])*$"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜