codz67 has asked for the wisdom of the Perl Monks concerning the following question:
Oh great and wise monks, I beseech your help.
I have this regex: ^regex*\.0-9
It matches regex.1
It must also match regex, but not regex.abc. .
It seems as though the ? doesnt make the \. optional. Please help.
#!/usr/bin/perl @filename = `ls | grep "^regex\.[0-9]"`; print @filename; ...
prints regex.1. I need it to print regex and regex.1:
#!/usr/bin/perl @filename = `ls | grep "^regex\.?[0-9]"`; print @filename;
Doesnt print anything.
Shouldnt the ? match the . zero or more times? If so why doesnt it print regex and regex.1 As for the .abc I need that to be excluded when it greps. So regex.abc and regex.xyz wont print.
Thank you for the help so far, I am still stuck on making this work. I will continue to try to make this work, if anyone could assist further I would be very thankful.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex \. help
by AnomalousMonk (Archbishop) on Nov 22, 2014 at 00:14 UTC | |
Re: Regex \. help
by Loops (Curate) on Nov 22, 2014 at 00:19 UTC | |
by AnomalousMonk (Archbishop) on Nov 22, 2014 at 00:47 UTC | |
by Loops (Curate) on Nov 22, 2014 at 01:30 UTC | |
by codz67 (Initiate) on Nov 24, 2014 at 19:59 UTC |
Back to
Seekers of Perl Wisdom