Reputation: 43
I'm trying to select a substring using regex and I'm going round in circles. I need to select everything before the first "_".
exampale URL - GI_2013_JUNE_10_VOL3_LASTCHANCE
So the result Im looking for from the URL above would be "GI". The text before the first "_" can vary in length.
Any help would be much apprecited
Upvotes: 0
Views: 832
Reputation: 121840
The regex would be:
^[^_]+
and grab the whole regex match. But as a comment says, using a substring function is more efficient!
Upvotes: 1
Reputation: 10302
^[^_]*
...is the expression you're looking for.
It basically says: Select everything that is not an underscore, starting at the beginning of the string.
Upvotes: 0