php - Replace all dot only in string, but not in numeric values -


i want replace occurrence of dot (.) in string not digits or numeric value. have given example

string : 10.10.2015 11.30 09/2007 83 hello.how.are.you $.### output : 10.10.2015 11.30 09/2007 83 hello how $ ### 

i tried using preg_replace in php

use non-capturing lookbehind group test if previous character digit or not

$string = '10.10.2015 11.30 09/2007 83 hello.how.are.you $.###'; $result = preg_replace('/(?<=[^\d])\./', ' ', $string); var_dump($result); 

explanation

(?<=[^\d])\.  -------- --      ^    ^      |    |      |    ------------------  escape `.` we're working literal      |                          dot rather "any character"      |      -----------------------  preceding non-digit character                                 don't include in replace group 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -