Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

php - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In addition to the other answers, here is one more

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...