I’m trying to capture all the output my code generates in the format "System.out.println(" until the first occurrence of ");" with the "Search regex patterns with notepad++" mode and replace it with "".
I have tested the following regex code:
System.out.println\(.*\);
So it works in a majority of cases but it’s a fragile regex because as soon as there is something like this further in the code on the same line:
System.out.println("sdsadas"); int blabla=1; Tony();
Then it takes all the text of that line until ); of tony and also deletes variables and functions.
Any idea how to be shure to capture the first occurence of ); ?
Thanks
PS: The issue has already been addressed here, but i didn’t find it earlier :), Maybe because my question was more specifically about notpad++ than REGEX in general.
>Solution :
You should make the dot in your regex pattern lazy/non greedy:
System\.out\.println\(.*?\);