Reputation: 177
For Example lets say I have those Lines
Example123 23 456 45 - car - bus
Example34 2123 - school
Example67 today - truck - Train
I want to delete ONLY expressions which located before "first" (-). How I can match the character position with Regex?
Upvotes: 1
Views: 1100
Reputation: 20504
The following will match everything before the first -
on a line:
^.*?(?=-)
This works by matching the start of the line, then matching any character 0 or more times, until it sees a "-" character, but doesn't include that in the match since it's a look ahead (?=-)
.
If you don't want to include the dash and white space change it to:
^.*?-\s*
Also you might have to check matches newline
as an option to work in Notepad++ so ^
matches start of a line.
Upvotes: 2