Re: Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5
> On Sep 8, 2019, at 6:36 PM, Olivier wrote: > > Jim Gibson writes: > >> On Sep 8, 2019, at 3:39 PM, Mike wrote: >>> >>> >>> It's probably best if you write a short script >>> that reads a __DATA__ section of data. >>> Then tell us what it does and what you expected >>> it to do. >>> >>> Off hand I don't see anything wrong with your regex, >>> but I don't know what you expect it to do. >>> >> >> I expect it to return a positive value if $t contains a number anywhere >> within it and put that number in the $1 capture variable. > > Well, that is not what is in your regex: you look for a decimal number > ending with 0 or 5, and it must be the last number of the line. > > What about something simple like: > >/(\d*[05])\D*$/ I prefer the explicit (?:…|…) structure that tells the reader that an alternate expression is being used. Also, the “zero or more” * operator can be very slow for long strings. > > The Regex Coach is your friend (and works well under wine). > > It alsways help to present with some sample data. If you want to use this regex, then you should test it yourself. I did. > > Best regards, > > Olivier > >>> >>> Mike >>> >>> >>> On 9/8/2019 4:34 PM, Jim Gibson wrote: On Sep 8, 2019, at 1:30 PM, Gautam Desai wrote: > Do you guys have any pointers ? $t =~ m{ ( # capture matched number in $1 \d* # match zero or more decimal digits [05] # followed by a '0' or '5' ) # end of capture (?: # followed by either: \D# a non-digit | # or $ # the end of the string ) }x >>> >>> -- >>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >>> For additional commands, e-mail: beginners-h...@perl.org >>> http://learn.perl.org/ >>> >>> >> >> Jim Gibson >> j...@gibson.org > > -- > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5
Jim Gibson writes: > On Sep 8, 2019, at 3:39 PM, Mike wrote: >> >> >> It's probably best if you write a short script >> that reads a __DATA__ section of data. >> Then tell us what it does and what you expected >> it to do. >> >> Off hand I don't see anything wrong with your regex, >> but I don't know what you expect it to do. >> > > I expect it to return a positive value if $t contains a number anywhere > within it and put that number in the $1 capture variable. Well, that is not what is in your regex: you look for a decimal number ending with 0 or 5, and it must be the last number of the line. What about something simple like: /(\d*[05])\D*$/ The Regex Coach is your friend (and works well under wine). It alsways help to present with some sample data. Best regards, Olivier >> >> Mike >> >> >> On 9/8/2019 4:34 PM, Jim Gibson wrote: >>> On Sep 8, 2019, at 1:30 PM, Gautam Desai >>> wrote: Do you guys have any pointers ? >>> $t =~ m{ >>> ( # capture matched number in $1 >>> \d* # match zero or more decimal digits >>> [05] # followed by a '0' or '5' >>> ) # end of capture >>> (?: # followed by either: >>> \D# a non-digit >>> | # or >>> $ # the end of the string >>> ) >>> }x >>> >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> > > Jim Gibson > j...@gibson.org -- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
regular expression
You are not doing anything with $t to test whether it works. Also you are not telling us what data you might test it with. Mike On 9/8/2019 6:41 PM, Jim Gibson wrote: On Sep 8, 2019, at 3:39 PM, Mike wrote: I expect it to return a positive value if $t contains a number anywhere within it and put that number in the $1 capture variable. On 9/8/2019 4:34 PM, Jim Gibson wrote: On Sep 8, 2019, at 1:30 PM, Gautam Desai wrote: Do you guys have any pointers ? $t =~ m{ ( # capture matched number in $1 \d* # match zero or more decimal digits [05] # followed by a '0' or '5' ) # end of capture (?: # followed by either: \D# a non-digit | # or $ # the end of the string ) }x -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5
On Sep 8, 2019, at 3:39 PM, Mike wrote: > > > It's probably best if you write a short script > that reads a __DATA__ section of data. > Then tell us what it does and what you expected > it to do. > > Off hand I don't see anything wrong with your regex, > but I don't know what you expect it to do. > I expect it to return a positive value if $t contains a number anywhere within it and put that number in the $1 capture variable. > > Mike > > > On 9/8/2019 4:34 PM, Jim Gibson wrote: >> On Sep 8, 2019, at 1:30 PM, Gautam Desai >> wrote: >>> Do you guys have any pointers ? >> $t =~ m{ >> ( # capture matched number in $1 >>\d* # match zero or more decimal digits >>[05] # followed by a '0' or '5' >> ) # end of capture >> (?: # followed by either: >>\D# a non-digit >> | # or >>$ # the end of the string >> ) >> }x >> > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5
It's probably best if you write a short script that reads a __DATA__ section of data. Then tell us what it does and what you expected it to do. Off hand I don't see anything wrong with your regex, but I don't know what you expect it to do. Mike On 9/8/2019 4:34 PM, Jim Gibson wrote: On Sep 8, 2019, at 1:30 PM, Gautam Desai wrote: Do you guys have any pointers ? $t =~ m{ ( # capture matched number in $1 \d* # match zero or more decimal digits [05] # followed by a '0' or '5' ) # end of capture (?: # followed by either: \D# a non-digit | # or $ # the end of the string ) }x -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5
On Sep 8, 2019, at 1:30 PM, Gautam Desai wrote: > > Do you guys have any pointers ? $t =~ m{ ( # capture matched number in $1 \d* # match zero or more decimal digits [05] # followed by a '0' or '5' ) # end of capture (?: # followed by either: \D# a non-digit | # or $ # the end of the string ) }x -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5
Do you guys have any pointers ? Thanks Gautam S Desai kidsforchess.org https://www.facebook.com/kidsforchess.suwanee.9 https://www.21stcenturyleaders.org/youth-ambassador-starts-nonprofit-donates-to-21cl/
Re: symlink to "pack"
On 2019-09-07 1:25 p.m., Jorge Almeida wrote: Sorry about the title, it's the best I can do... #!/usr/bin/perl use strict; use warnings; my $num=12; my $target=pack('n', $num); symlink($target, "foo") || die $!; It dies with "No such file or directory" No symlink is created. What I want is a symlink named "foo" pointing to a 2-byte string. Yes, it would be a broken symlink. (Yes, this is how I want it). Symlink() can create broken links, the problem is the target. What to do? (And why doesn't it work?) $ perl -le' use warnings; use strict; use Data::Dumper; $Data::Dumper::Useqq = 1; my $num = 12; my $target = pack "n", $num; print Dumper $target; ' $VAR1 = "\0\f"; On Unix/Linux a character in a file name can be any character except a slash '/' character because that is used to separate path elements, or a null "\0" character because that is what the C language uses to signify the end of a string. So your Perl string "\0\f" is read by C as a zero length string. John -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/