1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

@replace works case sensitive

Discussion in 'Support' started by Frank, Mar 16, 2013.

  1. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
    Yesterday I became almost desperate because @replacing strings did not work (as expected).
    I was really doubtful about my mind - until I RTFM.
    Of course @replace works case sensitive, but what I want to ask:
    Is there a way to bypass this or
    perhaps the possibility to enhance @replace with a "case insensitive - switch"?
     
  2. Stein Oiestad

    Joined:
    Sep 11, 2012
    Messages:
    55
    Likes Received:
    1
    Perhaps a function linke this ?

    ireplace=%@replace[%1,%2,%@upper[%3]]

    Test:

    echo %@ireplace[ABC,abc,"Test AbC"]

    Result: Test abc

    echo %@ireplace[ABC,abc,"Test abC"]
    Result: Test abc
    Is that your goal ?
     
  3. Stein Oiestad

    Joined:
    Sep 11, 2012
    Messages:
    55
    Likes Received:
    1
    Perhaps a function like this ?
    ireplace=%@replace[%1,%2,%@upper[%3]]
    Test:
    echo %@ireplace[ABC,abc,"Test AbC"]
    Result: Test abc
    echo %@ireplace[ABC,abc,"Test abC"]
    Result: Test abc
    Is that your goal ?
     
  4. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
    Hello Stein,

    that's a cool idea and actually what I want. It would also work with tcc/le without functions if I "upper" the 3rd parameter before the @replace. Thank you.

    But even more elegant would be an "ignore case" switch. ;)
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Vince Fatica's 4utils.dll / 4utiilsx64/dll plugin contains the function @XREPLACE which handles regular expression, including [aA] type pairs of upper- and lower case letters.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    And TCC has @REREPLACE.
     

Share This Page