0

Is there any way in notepad++ to add a word after a line that contain a specific word in that line? I have this line: "Varsta recomandata: 3+" and i want to edit to appear like this "<varsta>3+</varsta>" Thanks

I tryed to find and replace Varsta recomandata: with <varsta> but i don't know how to add to the end of the line </varsta>

jasonharper
  • 9,450
  • 2
  • 18
  • 42
alin
  • 11
  • 1
  • You can't have anything in the replacement that's outside of the text that was matched - so to add something at the end of the line, you simply need to match all the way to the end of the line. Something like `Varsta recomandata: (.*)$` => `\1`. – jasonharper Aug 27 '23 at 14:53
  • Completely untested, but what you want is the RegEx option enabled in your search-and-replace. So, you would search for something like: Varsta recomandata: (.+) and replace it with something like: \1 That will replace the \1 with the captured group of text. Good luck! – Tony B Aug 27 '23 at 14:54
  • Thank you very much jasonharper, it is almost done, but i see in the text file some lines are: Varsta recomandata: 2 ani+ and when i use the method given by you it replace me the whole line. Is there any way to stop before and edit? – alin Aug 27 '23 at 14:59
  • Does this answer your question? [Reference - What does this regex mean?](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – AdrianHHH Aug 27 '23 at 15:30
  • Welcome! You can try something like [this regex101 demo](https://regex101.com/r/5cRpR8/2) using a [negated character class](https://www.regular-expressions.info/charclass.html#negated). Don't forget, the answers you get are usually as good as you describe the problem. – bobble bubble Aug 27 '23 at 16:48

0 Answers0