今日、私はこのコード行に出くわした:トラブル理解re.findallパターン構文
re.findall(r"#[^:]+:([^#]+)", str)
私はfindall
機能が探しているもののパターンについて非常に混乱しています。特にr"#[^:]+:([^#]+)"
の意味は?
私は高校生ですので、簡単に言えばそれはすごいでしょう!
今日、私はこのコード行に出くわした:トラブル理解re.findallパターン構文
re.findall(r"#[^:]+:([^#]+)", str)
私はfindall
機能が探しているもののパターンについて非常に混乱しています。特にr"#[^:]+:([^#]+)"
の意味は?
私は高校生ですので、簡単に言えばそれはすごいでしょう!
それはこの意味です:
# => matches the character # literally (case sensitive) [^:] => Match a single character that is not : + => Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy) and is applied to the [^:] : => matches the character : literally (case sensitive) ([^#]+) => Capturing Group [^#] => Match a single character not present in this list (match anything other than #) + => Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy) and is applied to [^#]
をリテラルr
が引用された文字列がその中に何かがコンパイラに特別な意味を持っていない、あなたはいけないことを意味し、raw
テキストであることを意味することに注意してください任意の文字を二重引用符でもエスケープする必要があります!
[documentation](https://docs.python.org/2/library/re.html)を読んで質問を更新してください。 –
ドキュメントの補足として、正規表現をテストし、[regex101.com](https://regex101.com)でどのように動作するかについて説明します。 –
どうすれば更新できますか? – Joe