Assuming you’re doing this in PHP, you could use number_format()
or maybe even money_format()
Thread Starter
Pete
(@perthmetro)
Any chance in a bit/lot more help? I’m really bad at regex.
If you’re using PHP the functions I mentioned do not require regex knowledge.
Thread Starter
Pete
(@perthmetro)
I’m using a regex search and replace plugin, but if you have a another solution? I know nothing about php and regex unfortunately. 🙁
If you really want a regex solution, and you only want to change numbers with 6 or 7 digits, try something like:
$string = preg_replace(array('(\d\d\d)(\d\d\d)','(\d)(\d\d\d)(\d\d\d)'), array('$1 $2','$1 $2 $3'), $string);
If you can remove the money ($) character, number_format is a much better solution since it will work with any size number.