【发布时间】:2015-04-25 10:23:28
【问题描述】:
我试图弄清楚如何编写一个返回单词“AI”而不返回包含“ai”的单词的正则表达式。
我的猜测是,只有当“ai”左侧有一个空格并且“ai”右侧有一个空格时,我才需要使用返回“ai”的运算符。
但允许在两端使用标点符号。
目标是返回如下搜索结果:
"AI, the future of computing"
or
"Has AI finally arrived?"
as opposed to
"He said what?" (Notice ai is within the word "said".)
【问题讨论】:
标签: javascript regex whitespace metacharacters