LoginSignup
13
4

More than 5 years have passed since last update.

それは後方参照じゃない

Posted at

正規表現を用いた置換で,キャプチャーした文字列を置換文字列において参照することを「後方参照」と書いている文章をよく見かけますが,これは「後方参照」ではありません。「後方」ってどこよ?

後方参照というのは,たとえば (\d)\1 でゾロ目(同じ数字が二つ続いた文字列)を検索する場合の \1 のように 検索パターンの中で 後方(左の方)でキャプチャーした文字列を参照することです。

13
4
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
4