如何匹配中间任何其他字符的文本

时间:2018-01-13 09:49:57

标签: regex excel-formula google-sheets

我想匹配一个文本,即使

也应返回true

用户输入

BackOrdered
BAck ordered
B ack ordered
Back-ordered
backordered
BaCkOrdeRed

或任何具有类似含义的

我试过

=REGEXMATCH("Back ordered", "^[a-z A-Z]*$") 

但我的正则表达式也将Someabcd视为真。我只有在存在“延期交货”字时才能得到真实(可以包含空格,例如,应该是真的)

2 个答案:

答案 0 :(得分:1)

试试这个:

Beginning interaction for module default...
0% Created staging directory at: 'C:\Users\Molina\AppData\Local\Temp\appcfg5035433166099542506.tmp'
5% Warning: Google App Engine Java 7 runtime is deprecated.
8% Warning: See https://cloud.google.com/appengine/docs/deprecations/java7
11% Scanning for jsp files.
13% Compiling jsp files.
warning: [options] bootstrap class path not set in conjunction with -source 1.7
20% Scanning files on local disk.
25% Initiating update.
28% Cloning 1 static files.
31% Cloning 25 application files.
40% Uploading 2 files.
52% Uploaded 1 files.
61% Uploaded 2 files.
68% Sending batch containing 2 file(s) totaling 3KB.
73% Initializing precompilation...
90% Deploying new version.
95% Closing update: new version is ready to start serving.
98% Uploading index definitions.

Update for module default completed successfully.
Success.
Cleaning up temporary files for module default...

基本上就是这样:

^[\s-]*b[\s-]*a[\s-]*c[\s-]*k[\s-]*o[\s-]*r[\s-]*d[\s-]*e[\s-]*r[\s-]*e[\s-]*d$

但在每个字母之间添加了^backordered$ (零个或多个空格或连字符)。

你应该打开不区分大小写的选项。

Try it here.

答案 1 :(得分:1)

如果您的环境是Excel并且用户输入位于单元格 A1 中,则在单元格 B1 中输入:

=LOWER(SUBSTITUTE(SUBSTITUTE(A1," ",""),"-",""))="backordered"

enter image description here