繁体   English   中英

在正则表达式中匹配单词的中间或整个单词

[英]Match the either middle of a word or the entire word in regex

我想都匹配propositionsit在字的中间。 我该如何使用正则表达式呢?

我知道您可以执行类似^(proposition|sit)$但是我想知道是否还有其他方法。

这是允许的字符串(不视为多行条目):

proposition
sit

这将是一些不允许的字符串,这些字符串也不被视为多行条目:

Proposition
position
SIT
stuffit_archive.sit
proposition 65

我正在10.11.6 El Capitan下的bash 3.2.57(1)-release中使用if语句。

试试这个^.*(proposition|sit).*$ 另外,请确保将调用此正则表达式的命令设置为不区分大小写。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM