私はコードや正規表現のこの行は私だけを見パニック...誰かがこのRegExについて私に説明できますか?
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/
誰かがそれが何をするか少しで少し説明していただけますか? おかげで、G
私はコードや正規表現のこの行は私だけを見パニック...誰かがこのRegExについて私に説明できますか?
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/
誰かがそれが何をするか少しで少し説明していただけますか? おかげで、G
は、ここで私は抽出することができますものです:
^
文字列の先頭。(?:
不一致のグループ。[^#<]*
#
または<
以外の任意の連続する文字数。(<[\w\W]+>)
<anything_goes_here>
のような文字列と一致するグループ。[^>]*
>
ではない任意の数の文字が連続しています。|
の後の部分は、最初の1が失敗した場合にしようとする第二の正規表現を表します。その一つが#([\w\-]*)
です:
#
は#
文字に一致します。それほど複雑ではありません。([\w\-]*)
は、任意の数の単語文字またはダッシュに一致するグループです。基本的にはThings-of-this-form
$
を正規表現の末尾に付けます。私は正規表現のプロではありませんので、私が間違っている場合は私を修正してください。
^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)
Assert position at the start of the string «^»
Match the regular expression below «(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)»
Match either the regular expression below (attempting the next alternative only if this one fails) «[^#<]*(<[\w\W]+>)[^>]*$»
Match a single character NOT present in the list "#<" «[^#<]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the regular expression below and capture its match into backreference number 1 «(<[\w\W]+>)»
Match the character "<" literally «<»
Match a single character present in the list below «[\w\W]+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match a single character that is a "word character" (letters, digits, etc.) «\w»
Match a single character that is a "non-word character" «\W»
Match the character ">" literally «>»
Match any character that is not a ">" «[^>]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Assert position at the end of the string (or before the line break at the end of the string, if any) «$»
Or match regular expression number 2 below (the entire group fails if this one fails to match) «#([\w\-]*)$»
Match the character "#" literally «#»
Match the regular expression below and capture its match into backreference number 2 «([\w\-]*)»
Match a single character present in the list below «[\w\-]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match a single character that is a "word character" (letters, digits, etc.) «\w»
A - character «\-»
Assert position at the end of the string (or before the line break at the end of the string, if any) «$»
Created with RegexBuddy
あなた自身とGoogleの各コンポーネントの正規表現を壊すことはできませんか?それはかなり簡単です。 – Blender
私は始めましたが、 '[\ w \ W]'は私には意味がありません。あなたは何が答えを見るのが好奇心。 –
@Blenderあなたは正しいです。実際に私はそれについてMDNで読んでいます。 – Gnijuohz