Reputation: 2584
I am using sublime on Mac I have something like this
Q21162;E5QCE7
E5QCF5;P91040
E5QCF6;E5QCF8;P34558
E5QCG0;Q09499
E5QCG2
I want to get rid of everything after the first ; so I want the output like this
Q21162
E5QCF5
E5QCF6
E5QCG0
E5QCG2
Upvotes: 7
Views: 18455
Reputation: 11638
regular expression is your best friend
forget about the IDE you are using and do some research on how to use regexes.
Or you can use the built-in regular expression parser included in sublime:
https://docs.sublimetext.io/guide/usage/search-and-replace.html
this is the regex you are looking for:
s/[^;]*$//
I'm assuming you want to remove the text after the last occurrence of a semicolon in a line
Upvotes: 0
Reputation: 296
An alternative to using regular expressions would be using the multi cursor editor to select all the semicolons, then highlight to end of line, then delete.
Using the exact example in the question, this worked perfectly for me:
Done using Sublime 3 on Debian - I'm assuming this'll work elsewhere too?
Regular expressions are wonderful, but overkill in this case where a couple of keyboard shortcuts will do the job nicely.
Upvotes: 6
Reputation: 1244
The following worked for me with a regular expression:
In Sublime:
^([^;]*);.*$
\1
I tested it on Windows, on Mac you probably have to use the CMD instead of the CTRL key.
Upvotes: 28