Search code examples
regexnotepad++

find line with specific string and move this string to the beginning of the line


is there a way to move specific srtring of the line to the beginning of the line with Notepad++?

here's lines:

Chevrolet '96 Corvette COUPE [AP] [2] 
Chevrolet '96 Corvette COUPE [AP] [2] [RM]
Chevrolet '96 Corvette GRAND SPORT [AP] [2] 
Chevrolet '96 Corvette GRAND SPORT [AP] [2] [RM]
Chevrolet Camaro Z28 [AP] [2] 
Chevrolet Camaro Z28 [AP] [2] [RM]
Chevrolet Camaro Z28 30th Anniversary [P] 
Chevrolet Camaro Z28 30th Anniversary [P] [RM]
Chevrolet Corvette '67 427COUPE [3] [US/EU] [A] [4]

here's what I want them to be:

Chevrolet '96 Corvette COUPE [AP] [2] 
[RM] Chevrolet '96 Corvette COUPE [AP] [2]
Chevrolet '96 Corvette GRAND SPORT [AP] [2] 
[RM] Chevrolet '96 Corvette GRAND SPORT [AP] [2]
Chevrolet Camaro Z28 [AP] [2] 
[RM] Chevrolet Camaro Z28 [AP] [2]
Chevrolet Camaro Z28 30th Anniversary [P] 
[RM] Chevrolet Camaro Z28 30th Anniversary [P]
Chevrolet Corvette '67 427COUPE [3] [US/EU] [A] [4]

Solution

  • Is [RM] the only substring you want to move to the beginning of the line? In that case do the following: Open the replace window with Ctrl + h then select "Regular expression" under "Search Mode".

    Then search for the following:

    (.*?)\[RM]
    

    And replace it with the following:

    \[RM] \1