Reputation: 23
Example:
a ; user ; name ; pass ; 123 ;
b ; login ; name ; password ; def;
c ;
d ;
e ; email ; [email protected] ; pass ; 789 ;
lines 1,2,5 have 5 semicolons and lines 3,4 have 1 semicolon I want line 3 and 4 deleted.
result:
a ; user ; name ; pass ; 123 ;
b ; login ; name ; password ; def;
e ; email ; [email protected] ; pass ; 789 ;
Upvotes: 2
Views: 140
Reputation: 72874
Use the following pattern in the regex matching the line to be replaced:
^[^;]*;[^;]*$
[^;]
matches any character except the semi-colon.
The characters ^
and $
at the beginning and the end mark the start and the end of the line respectively.
Upvotes: 1