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.
次の正規表現が一致しない理由を誰か教えてください。文字列が "rect(" または "rect (" で始まり ")" で終わることを検証する必要があります
rect (a,a,a,a)
正規表現
(^rect+\s*\()+\)$
(and をエスケープしてみてください):
(
)
^rect\s*\(.*\)$
これは通常、括弧が正規表現で特別な意味を持っているため必要です。そのため、リテラルに一致させたい場合、(または)エスケープする必要があります。
これは一致します:
rect
次のものを使用します。 ^rect\s*\(.*\)$