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_name>
To do this I used this regex:
Expand|Select|Wrap|Line Numbers
- $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_here>
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.