Search code examples
sublimetext3sublimetext

deleting all characters after a semicolon


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

Solution

  • The following worked for me with a regular expression:

    In Sublime:

    1. Open the replace panel with CTRL + H
    2. Make sure that regular expressions are enabled. It is the left icon ".*" in the same row as the search field (ALT + R).
    3. Enter in "Find What": ^([^;]*);.*$
    4. Enter in "Replace With": \1
    5. Find and replace all

    I tested it on Windows, on Mac you probably have to use the CMD instead of the CTRL key.