Reputation: 786
I want to match everything beginning from second .
, including .
Regexp: /(?<=\d\.\d+)\..*/g
. Playground regex101
It does not work for strings 1232..233232
.
Upvotes: 0
Views: 65
Reputation: 21160
When reading your question literally.
I want to match everything beginning from second
.
, including.
This would do the trick:
[.][^.]*([.].*)
Leaving the resulting answer in group 1. Keep in mind that [^.]
also matches newline characters, if you don't want this add \n
to the character negation class.
Upvotes: 0
Reputation: 3001
as @WiktorStribiżew points out the regex don't test for 1212.2e1.121212
os this might be a better solution.
/(?<=^[^.]*\.[^.]*)\..*/
since it will also test for this
You can do this regex101, this will begin including from the second .
including it.
Regexp: /(?<=\d?\.\d*)\..*/g
You need to use *
(include 0 to x elements of this character) instead of +
(include 1 to x of this character)
I have added a ?
after your first \d
to handle the case if it starts with a .
and not a digit.
Upvotes: 1