Forum Moderators: coopster
is turning:
4 in. ...$12.64
into
4 in. ....64
im trying to write an expression that will match:
...add $[either 9879.09,98 - dollars with or without cecimal and cents]
or
...$[either 9879.09,98 - dollars with or without cecimal and cents]
i can get it to match on regular expression tools online, but when i call it in PHP (4.3.4) on the server, its does things like the above example. any ideas?
a whole bunch of stuff with add $[either 9879.09,98 - dollars with or without cecimal and cents] in the middle
What is that number you give in the example? It's neither a european or an american number format. Do you mean "1.987.909,98" (in other words, European format for large numbers and decimal places)?
Is the "$[either " always present? I'm not sure whether this *is* your data or *describes* your data.
$text = preg_replace("/\\\$/","",$text); $text = preg_replace('/\$/',"",$text); Note: Because MySQL uses the C escape syntax in strings (for example, `\n'), you must double any `\' that you use in your LIKE strings. For example, to search for `\n', specify it as `\\n'. To search for `\', specify it as `\\\\' (the backslashes are stripped once by the parser and another time when the pattern match is done, leaving a single backslash to be matched).
Yeah, this is confusing stuff. Other explanations I've seen in the preg_replace [php.net] User Contributed notes:
...The reason for this is that before the regex engine can interpret..., PHP interprets it. Thus, you have to escape your backslashes twice: once for PHP, and once for the regex engine.
...and there are yet even more in the ereg_replace [php.net] User Contributed notes. I can't tell you if that's how it works or not, but I haven't found a better explanation [webmasterworld.com] yet.
ergophobe: i was just using an example, as in a currency string with decimal place and cents, or currency without decimal place and cents. like $9080.93 or $98.
coopster, thank you. i spent literally 12 hrs on this. i'm not very smart, hehe. actually, i read as much as i could about regular expressions online, and am starting to get the hang of them, but this was causing me alot of grief.