match [ or ] character

Discussion in 'Cadence' started by vlsidesign, Jul 14, 2007.

  1. vlsidesign

    vlsidesign Guest

    I am trying to search for labels that have brackets [ ], and replace
    them with < >. I am having trouble using rex pattern matching, it
    "seems" like I am not able to do this. I tried using backslash before
    the bracket.
     
    vlsidesign, Jul 14, 2007
    #1
  2. vlsidesign

    S. Badel Guest

    I am trying to search for labels that have brackets [ ], and replace
    An easy way to do this is to use parseString.

    x = parseString( text "[]" )
    when( length(x) > 1
    text = strcat( car(x) "<" cadr(x) ">" )
    )

    Using regexps, carefully escape the backslashes :

    rexCompile("\\[\\([0-9]+\\)\\]")
    rexReplace(text "<\\1>" 1)


    Stéphane
     
    S. Badel, Jul 16, 2007
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.