では、次の正規表現は実際にはどういう意味ですか?
str_([^_]*)(_[_0-9a-z]*)?
そしてそれは等しい^str_[^_]*(_[_0-9a-z]*)?ですか?
str_これらの文字に文字通り一致します
([^_]*)アンダースコアではない0回以上の任意の文字に一致します
(_[_0-9a-z]*)?別の下線に一致し、次に0個以上の文字に一致します_0-9a-z。この最後の部分はオプションです。
私の回答へのコメントで述べたように、 http: //gskinner.com/RegExr/は、正規表現を入力すると、正規表現に関するすべてを説明します。
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
^at the startは、入力^str_[^_]*(_[_0-9a-z]*)?したものの行頭でのみ一致する必要があることを意味します。
str_([^_]*)(_[_0-9a-z]*)?
だから、正規表現について話しましょう:
1) -このシンボルではない任意のカウント(ゼロが可能)シンボルを([^_]*)キャッチします。()*[]^_
2)(_[_0-9a-z]*)?-生きるべきか、死ぬべきか、そしてシーケンスの開始記号と末尾のシーケンスを?キャッチします。()_*[]_ a,b,c,..,z0,1,..9