Reputation: 1185
I'm trying to write the regex to match
filename_with_multiple_exts
as the first group andaaa.bbb.user.js
as the second groupof the following string:
filename_with_multiple_exts.aaa.bbb.user.js
This is what I have currently (test):
(\.([^\.]*[\.])*)([^\.]+)$
But it isn't exactly what I'm searching for.
Upvotes: 1
Views: 1812
Reputation: 627607
You may split the string at the first dot using
([^.]*)\.(.*)
See the regex demo. Anchors are not required, you might just want to tune the regex if you operate on individual lines, if not, it will work as is.
Details
([^.]*)
- Group 1: any 0 or more chars other than dots\.
- a dot(.*)
- Group 2: any 0 or more char (usually, other than line breaks, but that varies from regex flavor to flavor).See a visual graph, too:
Upvotes: 2