Next | Regular Expression Mastery | 93 |
Let's apply what we know
Someone showed up on IRC asking this today:
``How do I remove the characters from the last x to the end?''
s/x.*//; # WRONG
s/(.*)x.*/$1/; # Right, but slow
s/x[^x]*//; # WRONG
s/x[^x]*$//; # Ahhhh. (1/3 faster)
End of digression
Next | Copyright © 2002 M. J. Dominus |