[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Simon Williams wrote: > Does anyone know of a good tutorial for regex? The perl man page perlretut is OK. > I know basic syntax, but I never know what to search for when I want > something more complex. For instance? > How can I tell it to keep searching and replacing (even on text it's > already replaced) until it isn't possible to replace any more? Normally /g on the end, mean ing global. > Also, I can't figure out how to use backreferences. That depends which system you're using. > If I have some string which may or may not have an arbitrary number of > /'s at the start, how do I get it to print the string without all the > starting /'s? Do you want to make them go away for ever or just fund the bit that follows. > This is meant for PHP, but I'm currently trying to test the regex on > grep/sed. Assuming you're using the PHP Perl like regular expression functions, you'll find that sed and grep, or even egrep don't cut the mustard. You want to try something like: perl -ne 'print if /regex/' testfile.txt This will act like grep but use all the Perl goodness. Steve -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html