I need a regex that will match everything before a last dot in my string. For example, I have text like this:
if_blk4.if_blk1.if_blk1
I would like to get the if_blk4.if_blk1.
Thanks!
To match everything up to (but not including) the last dot, use a look ahead for a dot:
.*(?=\.)
The greedy quantifier * makes the match include as of the input much as possible, while the look ahead (?=\.) requires the next character in the input to be a dot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With