user898741
user898741

Reputation:

Regex - Remove all matches leaving the last

I need a regex to remove dots in an number but just leaving the last. Example:

12312.123132.12312.131.3131.3123.13123.1231

to

12312123132123121313131312313123.1231

I tried some expressions but none worked.

Upvotes: 2

Views: 1942

Answers (2)

user557597
user557597

Reputation:

In addition to the other answers, here is one more

[.](?!\d*$)
or
[.](?![^.]*$)

Upvotes: 3

user5398447
user5398447

Reputation:

This regex detects all but the last dot: [.](?![\w]{2,4}$)

Upvotes: 1

Related Questions