in reply to quick regex question

No 12s31/2002 because:
  • The subtitution part of the regexp is treated as a double quoted string and \s is not a valid escape (enabling warnings would have told you that)
  • Only the first occurance is replaced unless you specify the /g modifier.
    You want  s/\///g;
    Unless you wanted a literal null character in which case its \0 in the substituion (I think I don't have my camel with me).

    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
  • Replies are listed 'Best First'.
    Re: Re: quick regex question
    by Grygonos (Chaplain) on Jul 15, 2003 at 14:11 UTC
      in response to the responses..

      • thanks . I meant to post the one without the /s hehe I had taken it out and grabbed the wrong one to paste. thanks . I forgot about the g mod
      • tr does seem like a better option.
      • I don't choose the delimiter unfortunately :( unless you are referring to the / in the regex... which I didnn't know there was any way to use another one? did you mean $row[0] =~ s,\/,,glike using a different regex delimiter? or did you mean the /'s in the field?


      • Thanks for all your responses .. problem solved... multiple ways :)
        Yeah, you can use (just about) anything as your regexp delimiter, and if you use something other than / you don't need to escape it. So s,/,,g or tr,/,,d (or whatever other delimiter strikes your fancy; I'm fond of matched delimiters like tr{/}{}d, but that's just me).