in reply to How do I use regex to strip out specific characters in a string?

How about
$stamp =~ s/.{3}(.{6}).{5}/$1/gosix; #strips first day/year chars $stamp =~ s/://gosix; #strips the colon
Of course, I suck at regexes, so this only makes sense in my head...
  • Comment on Re: How do I use regex to strip out specific characters in a string?
  • Download Code

Replies are listed 'Best First'.
Re: Re: How do I use regex to strip out specific characters in a string?
by dga (Hermit) on Aug 23, 2001 at 01:34 UTC

    RE notes: A few things to take note of since it seems that you may include those qualifiers on all matches which are not always needed or wanted.

    s/://gosix

    • The o says to only compile the RE once which is the case anyway since the pattern is a literal.
    • the s folds lines in the match to one big line making . match \n which in this match a noop.
    • the i makes the match case insensitive which slows down the match. Additionally, the : is not affected by case.
    • the x allows comments to be included in the match none of which have been included.
    • as noted before tr/://d ( or y/://d ) is much more efficient to eliminate or change single characters.
      Whooops...thanks dga, I was smoking a little too much of the old crack this afternoon, had gimsox on the mind :-) Thanks for the pointers/clarification.