问题:
Is there a simple way to ignore the white space in a target string when searching for matches using a regular expression pattern? 使用正则表达式模式搜索匹配项时,是否有一种简单的方法可以忽略目标字符串中的空格? For example, if my search is for "cats", I would want "c ats" or "ca ts" to match. 例如,如果我搜索的是“猫”,则希望匹配“猫”或“猫”。 I can't strip out the whitespace beforehand because I need to find the begin and end index of the match (including any whitespace) in order to highlight that match and any whitespace needs to be there for formatting purposes. 我无法预先去除空格,因为我需要找到匹配项的开始和结束索引(包括任何空格)以突出显示该匹配项,并且任何空格都需要用于格式化。