Reputation: 1
I have a strings for example
Apple_Banana_Orange_PACK101_10
Pear_Apple__Grapes_BUNDLE222_06
I need a regex string that will match everything before _PACK or _BUNDLE and nothing else.
So for example I want the first string to return
Apple_Banana_Orange
I have tried:
If you're looking to capture everything up to "abc":
/^(.*?)(_PACK|_BUN)/
And a few other options but still struggling. Any help appreciated
Upvotes: 0
Views: 45
Reputation: 10998
You can simply do
^(.*)(_PACK|_BUNDLE)
where group 1 is what you want to catch
Upvotes: 0