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.
name = value形式の文字列から正規表現を介して名前を抽出する方法は? 文字列から取得したい
saf asfgo = ==slwin[(*]? m||a=vd8228J)_+ sPiof+_ = vsfs=+":~lue3
名前のみ:
saf asfgo m||a sPiof+_
最初の等号とその前の空白はありません。
更新。^.+(?=[ \t]*?=) upd2を使ってみました。ごめん。私はすぐに決定を見つけました:^.+?(?=[ \t]*=)
^.+(?=[ \t]*?=)
^.+?(?=[ \t]*=)
これを試して
if ($subject =~ m/(?im)^([^=\r\n]+?)\s*=\s*([^=\r\n]+?)$/) { $name = $1; $value = $2; } else { $name = ""; $value = ""; }