13

I try replace author Full name with article title I have a list of articles, similar like this:

  1. Albershein P., Nevis D. J. A method for analysis of sugars in plant cell wall polysaccharides by gasliquid chromatography // J. Carbohydrate Research. – 1967. – Vol. 5, № 3. – Р. 340–345.

And I have Regex for it

(?'n1'^\d{3}\. )(?'n2'(?:(?:[A-ZА-Я][-a-zćа-я ]+)?([A-ZА-Я][-a-zćа-я]+\xA0[A-ZА-Я]\.(?:\xA0[A-ZА-Я]\.){0,2}\,?)(?: \[et al\])? ?)+)(?'n3' [^\/]+[\/]{2})

but replace like

\k{n1} 

or

\k'n1'

doesnt work

we try this in perl but have the same result

ekad
  • 14,436
  • 26
  • 44
  • 46
Victor Dronov
  • 139
  • 1
  • 12
  • 1
    Try just numeric group index `\1` or `$1`. Groupname would be [\g](https://regex101.com/r/mR0nU9/1), `${n1}` in replace or maybe `\k{n1}`,`\g{n1}` but none seems to work in np++. – bobble bubble Nov 10 '15 at 15:49
  • In Perl you might try `$+{name}` on the replacement side, but it should be in the form of eval `s///eg` (not sure about the eval) –  Nov 10 '15 at 16:34
  • \1 \2 ... working fine in simple samles, but in this case it dosent work (you can try) – Victor Dronov Nov 11 '15 at 10:27
  • In official help np++ I found what I need but it doesnt work Details here http://docs.notepad-plus-plus.org/index.php/Regular_Expressions – Victor Dronov Nov 11 '15 at 10:29
  • I cannot get this regex working at https://regex101.com/ – Decula Oct 23 '18 at 19:06
  • regex101.com is a really powerful regex platform. The explanation for the regex is pooooooooowerful! – Decula Oct 23 '18 at 19:13
  • how should I use regex to replace this reference? [23] D. Spina, M.-H. Peetz, and M. de Rijke. Active learning for entity filtering in microblog streams. In Proceedings of the 38th International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR ’15, pages 975 978. ACM, 2015. – Decula Oct 23 '18 at 20:33
  • @Decula Which result you are expect to get? – Victor Dronov Nov 07 '18 at 12:12
  • **Regex:** `^\[?(?\d{1,3}\.?)\]? (?((and )?(-?[A-Z]\. ?)+(de )?[A-Z][a-Z]+[,.] )+)(?.+)` **Replace with:** `$+{n1} $+{n3} // $+{n2}` **Output:** `23 Active learning for entity filtering in microblog streams. In Proceedings of the 38th International ACM SIGIR Conference on Research and Development in Information Retrieval, SIGIR ’15, pages 975 978. ACM // D. Spina, M.-H. Peetz, and M. de Rijke. ` – Victor Dronov Nov 07 '18 at 15:53

1 Answers1

24

Try using in regex (?<groupname>something to match)

And in replacement: $+{groupname}

Jakub Binkowski
  • 553
  • 1
  • 5
  • 10
  • ensure you selected "Match case" and "Regular expression" in the Replace tab. – Decula Oct 23 '18 at 18:48
  • 2
    @Decula I do not need Match case. Question was only about named groups which in official notepad++ documentation described incorrect. – Victor Dronov Nov 07 '18 at 12:05
  • @Jakub Binkowski Can you please elaborate on this usage? I can't find it in the documentation. I noticed that I can use a single `{groupname}` for conditionals, but I have to prefix it with `$+` if I want to use the content in replacement – George Menoutis Mar 10 '22 at 08:28