Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^3: Regex \. help

by Loops (Curate)
on Nov 22, 2014 at 01:30 UTC ( [id://1108067] : note . print w/replies, xml ) Need Help??

in reply to Re^2: Regex \. help
in thread Regex \. help


Yeah you're right about that. I confess to removing the non-capturing annotation for simplicity sake. Here's a slightly different version where the \d* isn't redundant:

my @t = qw( regex regex. regex.1 regex.12 regex.1a regex.a r +egex.a1 oregex.2 ); say s/^regex(?!\.[^\d])(\.\d*)?/|$&|/r for (@t);
|regex| |regex.| |regex.1| |regex.12| |regex.1|a regex.a regex.a1 oregex.2

Replies are listed 'Best First'.
Re^4: Regex \. help
by codz67 (Initiate) on Nov 24, 2014 at 19:59 UTC
    #!/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 and 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.