Use the following regular expression to capture everything between a dot character (.
) and an underscore (_
):
/\.([^_.]+)_/
Breakdown:
/
- starting delimiter\.
- match literal dot (.
) character[^_.]
- character class that matches any character that's not a.
or_
one or more times_
- match literal underscore (_
) character
/
- ending delimiter
The preg_replace()
statement should look like:
preg_replace('/\.([^_.]+)_/', '.', $A);
Effectively, it says: "Replace everything between a .
and _
with a .
".
Output:
12854827.IDS.0 12854827.892.0
12854827.IDS.0 12854827.892.0