help with regular expression
Posted: Thu Dec 30, 2004 8:51 am
Hello
I would like to use ereg_repace to replace any occurrence of the '_' letter (that isn't preceded by a \) by a '?'
for example the string 'test_' should be converted to 'test?'
but the string 'test\_' should not be matched by the pattern and thus NOT be replaced to 'test\?'
this is what I tried:
but obviously this isn't working
any help would be appreciated
I would like to use ereg_repace to replace any occurrence of the '_' letter (that isn't preceded by a \) by a '?'
for example the string 'test_' should be converted to 'test?'
but the string 'test\_' should not be matched by the pattern and thus NOT be replaced to 'test\?'
this is what I tried:
Code: Select all
$string = ereg_replace('^[\\]_', '?', $string);any help would be appreciated