简体   繁体   English

不区分大小写的RegEx模式

[英]Case insensitive RegEx pattern

I want to search for strings that have: Code[spaces]VARCHAR 我想搜索具有以下内容的字符串: Code[spaces]VARCHAR

Currently I'm using: \\bCode\\s+VARCHAR\\b 目前我正在使用: \\bCode\\s+VARCHAR\\b

How would I make this case insensitive? 我如何使这个案例不敏感?

Reference 参考

Try this 尝试这个

/\bCode\s+VARCHAR\b/i

Or 要么

(?i)\bCode\s+VARCHAR\b

Explained here 这里解释一下

Which Regex engine do you use ? 你使用哪种Regex引擎? For most of them you can give a 'i' flag (insensitive) at the end of your regex 对于他们中的大多数人,你可以在正则表达式的末尾给出一个'i'标志(不敏感)

Like that : 像那样 :

/\bCode\s+VARCHAR\b/i

or sometimes as a function parameter : 或有时作为函数参数:

string.match("\bCode\s+VARCHAR\b", "i")

在java(以及其他语言)中,您可以在正则表达式中添加不区分大小写的标志(?i)

(?i)\bCode\s+VARCHAR\b

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

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