Regex in java and ignoring white spaces

I want to write a regex to match on a string and ignore white spaces. For example, 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:

/fs*os*os*bs*as*r/ 

Which basically has optional whitespaces in between every character.

链接地址: http://www.djcxy.com/p/77020.html

上一篇: 找到特定的字符串,但不出现在某个句子中时

下一篇: 正则表达式在Java中,并忽略空白