Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はこのようなパターンを持っています:
pattern = '.*class=(.*)'
そしてそれは私にこのような結果を与えます:
my_class=Hello your_class=Hi fclass=FHello class=That's What I need
基本的に、一部を含まclassず、一部のみを含む文字列を返す必要があると言いたいです。fclass my_class
class
fclass my_class
個々の行で正規表現を実行している場合は、^記号を使用して正規表現の先頭をターゲットにすることができます。
^
pattern = r'^class=(.*)'
そうでない場合は、単語の境界が役立つ可能性があります。
pattern = r'\bclass=(.*)'