I have the following code
<?php
$str="$str="115(JOHN DOE.) 900,000.00 SALARY. 45 AGE. ";
$str=preg_replace("/[a-zA-Z(),]/", "", $str);
echo $str=preg_replace('!\s+!', ',', $str);
?>
This output
115,.,900000.00.,45.,
but this is not exactly what i need, i need to consider period which is inside 900,000.00 and ignore that of JOHN DOE. , SALARY.,AGE.
How can i do that to get
115,900000.00,45
I.e i need regular expression to consider periods after numeric character only
Without trying to improve your code...this should do it:
I made it in three steps:
You can change this line:
with this:
to remove data without parentheses.
Output: