开发者

Regex in java and ignoring white spaces

I want to write a regex to match on a string and ignore white spaces. For examp开发者_JS百科le, a search for 'foobar' would match on 'foo bar'.


You can strip the spaces in both the pattern and search strings and use indexOf() if that's acceptable (might be a problem if you don't have enough memory to do so).

I don't think a regex would be a good idea, but you could basically make a pattern like:

/f\s*o\s*o\s*b\s*a\s*r/ 

Which basically has optional whitespaces in between every character.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜