I need help with a regular expression in Notepad++. I want to:
I tried using this regex to find the lines:
^(?=.*\()(?!.*\)).*$
Then, I used this in the Replace with field to add ) at the end:
\0)
I also tried using $0)
and other methods, but it either deletes the line or doesn’t work at all.
for example following is my sample list:
5years
Strta(Nicaragua)
3years
Ismtrtttu(Turkey)
2years
Frrtto(Spain
Lyears
Fulrttsta(Cuba)
0years
Chutrtrtl(UnitedKingdom)
Can someone help me find the correct regex and replacement pattern for this in Notepad++? Thank you!
You don't need any lookarounds, you can make use of a negated character class.
Find what:
^[^\n()]*\(\K[^\n()]*$
The regex matches:
^
Start of string[^\n()]*
Match 0+ times any character except (
)
or a newline\(
Match (
\K
Forget what is matched so far[^\n()]*
Match 0+ times any character except (
)
or a newline$
End of stringReplace with: the full match followed by a closing parenthesis:
$0\)
See a regex101 demo