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.
replaceこの関数を使用して、正規表現を使用してJavaScriptの各行に1文字を追加するにはどうすればよいですか?
replace
行頭の正規表現を使用します。
// X is the single char to add: str = str.replace(/^/gm, "X");
gmフラグは行全体で一致を引き起こします。
gm