这个regexp是什么意思?
那么,下一个regexp实际上意味着什么呢这个regexp是什么意思?,regex,Regex,那么,下一个regexp实际上意味着什么呢 str_([^_]*)(_[_0-9a-z]*)? 它是否等于^str.[^.]*(\u0-9a-z]*)??str.逐字匹配这些字符 ([^]*)匹配非下划线的任何字符0次或多次 ([\u 0-9a-z]*)?匹配另一个下划线,然后匹配0个或多个字符\u 0-9a-z。最后一部分是可选的 那么,让我们谈谈regexp: 1) ([^]*)-捕获任何计数中的()(可能为零)*符号[],这些符号不是^此符号 2) ([uuu0-9a-z]*)?-是或
str_([^_]*)(_[_0-9a-z]*)?
它是否等于
^str.[^.]*(\u0-9a-z]*)?
?str.
逐字匹配这些字符
([^]*)
匹配非下划线的任何字符0次或多次
([\u 0-9a-z]*)?
匹配另一个下划线,然后匹配0个或多个字符\u 0-9a-z
。最后一部分是可选的
那么,让我们谈谈regexp:
1) ([^]*)
-捕获任何计数中的()
(可能为零)*
符号[]
,这些符号不是^
此符号
2)
([uuu0-9a-z]*)?
-是或不是?
并捕获()
序列,序列的开头符号\uu
和序列的尾部,其中出现在任何计数*
集合[/code>中的任何符号,如
或0,1,…9
正如在我的答案的注释中所提到的,解释了正则表达式的所有内容(如果您将其放入其中)
str_([^_]*)(_[_0-9a-z]*)?
\ /^\ /^^^^\ /^^^
\/ | \/ |||| \ / |||
| | | |||| \ / ||`- Previous group is optional
| | | |||| \ / |`-- End second capture group (an underscore and any amount of characters _, 0-9 or a-z)
| | | |||| | `--- Match any amount (0-infinite) of previous (any character _, 0-9 or a-z)
| | | |||| `-------- Match any of the characters inside brackets
| | | |||| (0-9 means any number between 0 and 9, a-z means any lower case char between a and z)
| | | |||`------------- Match "_" literally
| | | ||`-------------- Start second capture group
| | | |`--------------- End first capture group (any amount of any character which is not underscore)
| | | `---------------- Match any amount (0-infinite) of previous (any character which is not underscore)
| | `------------------- ^ at the start inside [] means match any character not after ^
| | (In this case, match any which is not underscore)
| `--------------------- Start first capture group
`------------------------ Match "str_" literally
^
在^str_[^.]*([\u 0-9a-z]*)开头的^
仅仅意味着它应该只在您输入的任何内容的行的开头匹配。看看,可能对您有用。所以,让我们说“str_MOTH_clone”应该匹配regexp,对吗?哇。这是一个工具生成的,还是你真的键入了它?@li aung yip:键入了它,但我想一个用于此的工具将是一个好主意。谢谢你的主意投票给纯粹的球和努力。不过,下次请使用regexr@李昂业:嘿,regexr就是这么做的,谢谢你的提醒。