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.
精彩评论