我正在使用正则表达式模式

[^A-Za-z](email,|help|BGN|won't|go|corner|issues|disconected|We|group|No|send|Bv|connecting|has|Pittsburgh,|Many|(Akustica,|Toluca|cannot|Restarting|they|not|PI2|one|condition|entire|LAN|experincing|bar|Exchange,|server|Are|PA)|OutLook|right|says|Rose|Montalvo|back|computer|are|Jane|thier|Disconnected|Nrd|and/or|network|for|Appears|e-mail|unable|Connected|then|Broadview,|issue|email|shows|available|be|we|exchange|error|address|based|My|Microsoft|received|working|created|receive|impacted|WIFI|through|connection|including|or|IL|outlook|via|facility|Everyone's|servers|Also|message|"The|your|Status|doesn't|service|SI-MBX82.de.bosch.com,|next|appears|"disconnected"|Encryption|eMail/file|today|"Waiting|"send/receive"|but|it|trying|SAP|disconnected|e-mails|this|getting|can|of|connect|Incorrect|manually|is|site|an|folder"|cant|Other|have|in|Receiving|if|Plant|no|SI-MBX80.de.bosch.com|that|when|online|persists."|Customer|administrator|users|update|applications|"Disconnected"|SI-MBX81.de.bosch.com|The|on|lower|Some|It|contact|In|the|having)[^A-Za-z]


并申请但它在句子中找不到"Jane"

 "Issue with eMail/file Encryption Incorrect email address created for Jane Rose Montalvo."


当Jane以我正在使用的上述模式出现时。

可能是什么原因?

最佳答案

问题是您的正则表达式会在单词前后捕获\s,这也是匹配条件。

Hello Jane

因此,一旦捕获到Hello,就将其保留为Jane,因为它之前没有空格,因此无法对其进行匹配。您应将其声明为断言而不是匹配。

使用(?
http://regex101.com/r/lU7jH1/9

09-30 14:50