Menu

Find/Replace with RegEx

jzzh
2008-12-29
2012-11-13
  • jzzh

    jzzh - 2008-12-29

    Hallo,

    i want to replace
    VARCHAR2(5) or
    VARCHAR2(20) or
    etc.

    with VARCHAR(n CHAR)

    I'm able to find the occurrences with
    VARCHAR2.[0-9]+.

    But how to replace them ? Is it possible to do a RegEx replace ?

    Thanks,
    Jochen

     
    • jzzh

      jzzh - 2008-12-29

      This page helped:
      http://notepad-plus.sourceforge.net/uk/regExpList.php

      search:
      (VARCHAR2.[0-9]+).

      replace:
      \1 CHAR)

      Quite simple :)

       
  • Marc Kupper

    Marc Kupper - 2011-03-28

    It's not clear if you want the result to be "VARCHAR(n CHAR)" literally or "VARCHAR(20 CHAR)"

    For the first, you search for "VARCHAR2\(+\)" (without the quotes) and in the replace box you have "VARCHAR(n CHAR)"

    For the second you search for "VARCHAR2\((+)\)" and replace it with "VARCHAR(\1 CHAR)" resulting in
    VARCHAR(5 CHAR) or
    VARCHAR(20 CHAR) or

    Using \( and \) searches for left and right parentheses.
    Using () puts the stuff inside the () in one of nine hold buffers that you can then retrieve using \1, \2, \3, … \9

    You had said "I'm able to find the occurrences with VARCHAR2.+."  I suspect you had tried "VARCHAR2(+)" and that failed to match as the ( and ) were interpreted as being for a hold buffer.  It would have matched "VARCHAR21234" but not "VARCHAR2(1234)"