Reputation: 37
I have the following text:
lemap;Brsjmnb008528;Ask Toolbar;APNLLC;09/04/2014
I would like build a regular expression to get complete words before first semicolon, another one to get only all the words between first and second semicolon, etc.
Like this for the first use case:
[^;]*
Any suggestions?
Upvotes: 0
Views: 16124
Reputation: 287
The correct answer is
[^;]+
Using [^;]*
will match the nulls also
Upvotes: 1
Reputation: 16080
Try this regular expression:
^[^;]*
to get first word. ^
at the beginning matches the beginning of a string.
Upvotes: 0
Reputation: 91528
With this one:
^([^;]+);([^;]+);
you'll have the first word in group 1 and the second in group 2.
Upvotes: 1
Reputation: 46370
Your regex:
[^;]*
should work, but maybe you just need to capture what you match:
([^;]*)
Upvotes: 1