Loading ...
Sorry, an error occurred while loading the content.
 

Re: Problem while matching a string

Expand Messages
  • aktrapper2000
    ... variable(consisting of ... yes just escape them with a back slash , thus to check for ) use ) if( $b =~ /${a} )/ ) { print etc...} Greg
    Message 1 of 2 , May 31, 2007
      --- In perl-beginner@yahoogroups.com, "yaswanth krishna"
      <yaswanth.krishna@...> wrote:
      >
      > Hi..
      >
      > I had a problem while using regex containing scalar
      variable(consisting of
      > one paranthesis)..
      > Can anyone tell me how to handle this..
      >
      > It is considering that paranthesis as closing paranthesis for "if
      > condition".
      >
      > >perl -e '$a = "asdasd)"; $b =asda; if( $b =~ /${a}/ ){ print
      > "match\n"; }'
      > /asdasd)/: unmatched () in regexp at -e line 1.
      >
      > Is there any option while matching regex to consider metacharacters as
      > normal characters..
      >
      >
      > Thanks
      > Krishna..
      >
      >
      > [Non-text portions of this message have been removed]
      >

      yes just escape them with a back slash , thus to check for ")" use "\)"

      if( $b =~ /${a}\)/ ) { print etc...}

      Greg
    Your message has been successfully submitted and would be delivered to recipients shortly.