using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\/.*)\n(.+)\n*|(?<=^(\/.*)\n(?:.+\n)*)(.+)\n*";
string substitution = @"$2$4^=$1$3/$2$4\n";
string input = @"こんにちは
質問です
●Regular Expressionの使用環境
普通のテキストファイル
いま Sublime text を使ってますが無料のエディタなら何でも使います
●検索か置換か?
置換
●説明
各パラグラフの1行目を2行目以下の全ての行に加えたい
1行目はパラグラフごとに異なり、2行目以下はすべて異なる
●対象データ
/system/app
AntHalService
AutoRegistration
BasicDreams
/system/priv-app
AutoKillService
BackupRestoreConfirmation
●希望する結果
AntHalService^=/system/app/AntHalService
AutoRegistration^=/system/app/AutoRegistration
BasicDreams^=/system/app/BasicDreams
AutoKillService^=/system/priv-app/AutoKillService
BackupRestoreConfirmation^=/system/priv-app/BackupRestoreConfirmation
よろしくお願いします";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx