Re: another regx ...
"John W. Krahn" wrote: > > my ( $ref, $numt, $id, $ext ) = $PATH[ 7 ] =~ /(\w)-(\d{7})-(\d{2}).(\w+)/; Sorry, that should be: my ( $ref, $numt, $id, $ext ) = $PATH[ 7 ] =~ /(\w)-(\d{7})-(\d{2})\.(\w+)/; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: another regx ...
Jerry Preston wrote: > > Hi! Hello, > I am getting no where on this and it is not that hard. > I am trying to break down the following: > > D-2165033-10.TKB61a > > into > > D 2165033 10 > > and > > 4-2175587-08.TKB63a > > into > 4 2175587 08 > > using > > (( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ > /\w-(\d{7})-(\d{2}).[\w+|\d+]/; > > What am I doing wring? You need parentheses around the \w character class at the beginning and the character class at the end. The character class [\w+|\d+] matches a _single_ character that is either \w (A-Za-z0-9_) or a plus sign (+) or a vertical bar (|) or \d (0-9) or a plus sign (+). Since you probably don't want to match a plus sign or a vertical bar you shouldn't include them in the character class. Since the \w character class includes the \d character class there is no reason to use them both in the same character class. my ( $ref, $numt, $id, $ext ) = $PATH[ 7 ] =~ /(\w)-(\d{7})-(\d{2}).(\w+)/; Or you could do it this way: my ( $ref, $numt, $id, $ext ) = split /[-.]/, $PATH[ 7 ]; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another regx ...
Nkuipers wrote at Mon, 30 Sep 2002 19:24:18 +0200: > This idea is even simpler though not purely regex: > > $yourstring =~ s/\..*//; > @result = split /-/, $yourstring; Or still simpler: my ( $ref, $numt, $id, $ext ) = split /\W/, $string, 3; Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another regx ...
This idea is even simpler though not purely regex: $yourstring =~ s/\..*//; @result = split /-/, $yourstring; >= Original Message From "Mark Anderson" <[EMAIL PROTECTED]> = >-Original Question- > >D-2165033-10.TKB61a => D 2165033 10 > >and > >4-2175587-08.TKB63a => 4 2175587 08 > >using > >(( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ >/\w-(\d{7})-(\d{2}).[\w+|\d+]/; > >What am I doing wring? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: another regx ...
-Original Question- D-2165033-10.TKB61a => D 2165033 10 and 4-2175587-08.TKB63a => 4 2175587 08 using (( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ /\w-(\d{7})-(\d{2}).[\w+|\d+]/; What am I doing wring? -My Response- Your parens are in the wrong place. You aren't capturing the word (\w) character at the start. You're capturing four variables, but you only show breaking down into three. The . in your regexp represents any byte, not a literal period, for that you need \. [\w+|\d+] is confusing, since digits are included in \w, just use it. Try: ($ref,$numt,$id,$ext) = ($PATH[7] =~ /(\w)-(\d{7})-(\d{2})\.(\w+)/); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
another regx ...
Hi! I am getting no where on this and it is not that hard. I am trying to break down the following: D-2165033-10.TKB61a into D 2165033 10 and 4-2175587-08.TKB63a into 4 2175587 08 using (( $ref, $numt, $id, $ext ) = $PATH[ 7 ] ) =~ /\w-(\d{7})-(\d{2}).[\w+|\d+]/; What am I doing wring? Thanks, Jerry