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.
私は文字列を持っています:
"whatever( here i com ( asdfasDF ( ) ) ) go home"
"("最初と最後の間のすべてを抽出したい")":
"("
")"
" here i com ( asdfasDF ( ) ) "
それを抽出するのに適した正規表現は何ですか?
アップデート:
文字列に改行文字が含まれている場合、次のように動作します。
/\((([.|\s|\S])*)\)/
キャプチャ付きの貪欲な表現。例:
/\((.*)\)/
str = "whatever( here i com ( asdfasDF ( ) ) ) go home" p str[str.index("(")+1..str.rindex(")")-1]