Hi,
I am trying to change dashes to underscores in text file.
The reason is that I am having problems processing some xml tags
so I want to change this <merchant-name> to <merchant_nam e>
To do this I used this regex:
But for some reason, nothing is changed
Have I misunderstood something ?
The idea is that <anything-here> gets changed to <anything_her e>
There is data between the tags that should not be touched, it is just the tag
names themselves that I want to change.
In the file, there about 2000 tags which need changing.
Can anyone see what I am doing wrong ?
Thanks.
I am trying to change dashes to underscores in text file.
The reason is that I am having problems processing some xml tags
so I want to change this <merchant-name> to <merchant_nam e>
To do this I used this regex:
Code:
$pattern = '#<(\w+)-(\w+)>#'; $replacement = '<$1_$2>'; $source = preg_replace( $pattern, $replacement, $source, -1 , $count);
Have I misunderstood something ?
The idea is that <anything-here> gets changed to <anything_her e>
There is data between the tags that should not be touched, it is just the tag
names themselves that I want to change.
In the file, there about 2000 tags which need changing.
Can anyone see what I am doing wrong ?
Thanks.
Comment