[eluser]tkaw220[/eluser]
Hello pickupman,
Your regex is not working for me. But I do get a working code from Dreamweaver forum:
$result = preg_replace('/(\\d{3})(\\d{3})(\\d{3})(\\d{1})/', '${1}-${2}-${3}-${4}', $phone_str);
However, this regex applied to string with exact length (ie., 10 digits in this case) but break if the string has different length, ie., 14 digits. Any idea on how to modify it so that it always add a dash after every 3 digits at any string length?
Thank you very much and have a nice day.
Best regards,
Edwin