I looked it up but not sure. Android regex (like Java) can use the
\G
assertion, which means start at the end of the last match position.
Your problem can't be solved with a single regex, however it can be done with
two regex.
It's simple really.
Both are used in a replace all situation.
The first just clears out whatever you don't want.
Using your example its.
Find: "[^\\d.]+"
Replace: ""
The second is:
Find: "(?:(?!\\A)\\G|(\\.))([^.]*)\\."
Replace: "$1$2"
The last regex removes all the Dots after the first one (but NOT the first one)
Here is the breakdown of this regex:
(?:
(?! \A ) # Not at BOS
\G # Start at end of last match position
| # or,
( \. ) # (1), One time, The first Dot in the string
)
( [^.]* ) # (2), Optional any chars
\. # Until we find the next extra Dot to remove
Input:
a12.334tyz.78x
Output:
12.33478