Reputation: 63
I am using eclipse v4.4.2 Text file contents have these lines:-
tosh1
tosh2
tosh3
tosh4
tosh4
tosh5
I am trying to match tosh4 and remove the lines. The regex ^\s+tosh4.*$ is returning with "String Not found"
Eclipse Search/Replace dialog I am not seeing what is wrong with the regex. Please help. Thx.
Upvotes: 3
Views: 1749
Reputation: 140427
Lets dissect your regex:
^ fine: start of line
\s+ wrong: 1 or more SPACES
tosh4
tosh1 tosh2 tosh3 are for sure not spaces. That is why already the beginning of your regex can match!
what should work better
^.*tosh4.*$
Matching any line that contains tosh4. But as you are looking for a regular expression that get matching lines deleted, we have to enhance that to:
^.*tosh4.*\R
\R
matches "new line" for all kinds of "new lines", no matter if \r\n Windows, or \n Linux, ... !
And for further reference: study the eclipse regex help pages, for example this here.
Upvotes: 3