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.
サンプル文字列
+ABC:108\r\nmessage a\r\n+ABC:117\r\nmessage b\r\n
ここに私の最初の正規表現があります
+ABC:(\d+)\r\n(.+)\r\n
グループ グループ 1: インデックス グループ 2: メッセージ
あなたの正確な問題はどこですか?
私はこの点を見ます:
文字どおりに一致させたい場合+は、正規表現でエスケープする必要があります\+ABC:(\d+)\r\n(.+)\r\n。verbatim string ( ) を使用して正規表現を定義する\場合は1 つだけ@"regex"
+
\+ABC:(\d+)\r\n(.+)\r\n
\
@"regex"
このオプションを使用しない場合、 は改行文字と一致しない[Singleline][1]ため、貪欲な問題にはなりません。.
[Singleline][1]
.
\r\nそれがあなたの改行であると確信していますか?たぶん\r?\n、以前はもっと柔軟でした。
\r\n
\r?\n