in reply to string replacement question

Hello,

You say :

I want to replace "C:\Program Files\180searchassistant\salmhook.dll" with "C:\Program Files\180searchassistant\salmhook.dll"

But these two string are identical ?!
As i understand it you have a problem with the backslash. It's not a real problem : escape the backslash

# note the use of single quotes $string = 'c:\foo\bar\weird program name.exe' ; # using another regexp separator for readability $string =~ s[foo\\bar][foo\\baz] ; # Or with / as the separator $string =~ s/foo\\bar/foo\\baz/ ;
Well, you can do this a gazillion ways there's no problems with the backslash ...

Now about replacing japanese characters with a regexp, as i understand this will call for unicode regexp. Supersearch will give you some result.

Replies are listed 'Best First'.
Re^2: string replacement question
by ww (Archbishop) on Dec 08, 2005 at 14:35 UTC
    But, pedantically, note the initial phrasing of OP's post DOES appear to specify a replacement:
    my goal is to replace C:\Program Files\180searchassistant\salmhook.dll to a custom file name "C:\japansese characters\japnaese character filename.exe"
    .

    nonetheless, ++ for the portion of your post re the backslash...

    and re OP's problem with multiple instances of "However I can't do the replacement globally because ... there are 2 places that hold filenames. " one might suggest that:

    • if OP knows the replaceable-instance always comes first, a simple regex, applied NON-globally (ie, *WITHOUT* a /g) should do the trick
    • if placement of the replaceable-instance is unknown or variable, my first thought would be to see if some other defining characteristic (context, for example) might be used in the regex
    FWIW....
    ww