I would like to create a regular expression that will replace a normal space with hard-breaking space according to my country typographical rules. It shouldn't touch HTML tags.
All spaces in these examples should be hard-breaking:
Numbers
1 000
10 000
100 000
1 000 000
etc..
Dates
17. 6.
17. 6. 2012
I came up with:
$pattern = '/((\d\.?)\s(\d))(?=[^>]*(<|$))/';
$text = preg_replace($pattern, '$2 $3', $text);
It can do all of these but: 17. 6. 2012 It won't replace the second space, so result is ->
17. 6. 2012
Thank you for any help!