Re: Regex question.
my $date =~ s#(\d{2})(\d{2})(\d{4})#$1/$2/$3#; That amazingly, doesn't have much performance loss to it. I just did: sub build_list_news { my $newstext = table DEFANGED_width='\100%\'; my %news = get_news(); foreach (keys %news) { $news{$_}{ctime} =~ s#(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})#$1/$2/$3 $4:$5:$6#; $newstext .= trtd DEFANGED_align='\center\'$news{$_}{ctime} - b$news{$_}{subject}/b/td /trtrtd$news{$_}{news}/td/tr; } $newstext .= /table; return $newstext; } and I get results at pretty much the same speed I was before I added the regex. So, even if there is a performance loss, it's still less then the lagtime between my workstation and the server it talks to through a 100base hub.. (which is by no means significant) i use #'s as delimaters here... some other character may be more appropriate I found them to be perfect when dealing with date/time stamps. Dennis At 07:49 AM 6/26/2003 -0700, Sara wrote: I have a database with the following fields. lname fnam M acct# mrmbirth Postdate Post# drln drfn m disch DOE,JOHN,R,00037839842,207337,02151956,04072003,01980,LastName,FirstName,L,04 102003 I have a very simple script which splits the delimiter , and shows the result in the same format as in database. I want to do following things using regex, but I have tried my options to my level best, ::) no results yet, 1- Remove all the leading 000 from any field like acct# = 00037839842 should be 37939842 and Post# should be 1980 2- Want to format dates like birth = 02151956 should be 02/15/1956 Any help?? Thanks, Sara. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex question.
1- Remove all the leading 000 from any field like acct# = 00037839842 should be 37939842 and Post# should be 1980 s/^0+//; 2- Want to format dates like birth = 02151956 should be 02/15/1956 my $date = $1/$2/$3/ if (/(\d\d)(\d\d)(\d\d\d\d)/) HTH Paul Kraus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex question
Scot Robnett wrote: I don't think you can check for the existence of an e-mail address without actually attempting to send mail to it. You can ping or traceroute a domain, but only the mail server associated with it knows if the username is valid or not. If this is wrong, somebody with information please reply to the list - it might be on the 'wish list' for a lot of people, including me. :) you can read more about this by typing: perldoc -q 'valid mail address' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex question
Scot Robnett wrote: Hey y'all, I got over my brain cramp and thought I'd share with the group in case it helps anyone trying to do something similar. I was making it way too complicated. All I needed was: if($email !~ /\w+@\w+\.\w{2,4}/) { # error stuff here } have you considered using email::valid? http://search.cpan.org/search?dist=Email-Valid -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex question
At 10-3-2002 09:36 -0500, fliptop wrote: Hey y'all, I got over my brain cramp and thought I'd share with the group in case it helps anyone trying to do something similar. I was making it way too complicated. All I needed was: if($email !~ /\w+@\w+\.\w{2,4}/) { # error stuff here } have you considered using email::valid? http://search.cpan.org/search?dist=Email-Valid Is there also a module or another way to test the existence of an email address ? Kind regards, Rene Verharen Please DO NOT reply to me personally. I'll get my copy from the list. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regex question
I don't think you can check for the existence of an e-mail address without actually attempting to send mail to it. You can ping or traceroute a domain, but only the mail server associated with it knows if the username is valid or not. If this is wrong, somebody with information please reply to the list - it might be on the 'wish list' for a lot of people, including me. :) Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] www.insiteful.tv Is there also a module or another way to test the existence of an email address ? Kind regards, Rene Verharen Please DO NOT reply to me personally. I'll get my copy from the list. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Regex question
Hey y'all, I got over my brain cramp and thought I'd share with the group in case it helps anyone trying to do something similar. I was making it way too complicated. All I needed was: if($email !~ /\w+@\w+\.\w{2,4}/) { # error stuff here } - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv -Original Message- From: Scot Robnett [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 09, 2002 3:47 PM To: [EMAIL PROTECTED] Subject: Regex question I'm trying to do a simple verification of an e-mail address format. I want to require: - 1 or more alphanumeric characters - followed by @ - followed by 1 or more alphanumerics - followed by a dot - followed by 2-4 alphanumerics. (for example, .tv, .com, .info) If the string doesn't fit these requirements, then I send them back to the form to re-enter the address. The problem is that using the code below, the program complains even when the address *is* formatted properly. Any ideas how I could reformat the expression better? ## if(($email !=~ /\w+[@]\w+\.\w{2}/) or ($email !=~ /\w+[@]\w+\.\w{3}/) or ($email !=~ /\w+[@]\w+\.\w{4}/)) { print Improperly formatted e-mail address! Please use your browser\'s back ; print button and make sure the e-mail address is entered correctly. ; } ## - Scot Robnett inSite Internet Solutions [EMAIL PROTECTED] http://www.insiteful.tv --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Regex question
On 3/9/02 1:46 PM, Scot Robnett [EMAIL PROTECTED] wrote: Hi Scot, I'm trying to do a simple verification of an e-mail address format. I want to require: - 1 or more alphanumeric characters - followed by @ - followed by 1 or more alphanumerics - followed by a dot - followed by 2-4 alphanumerics. (for example, .tv, .com, .info) What about things like .co.uk? And what about things like [EMAIL PROTECTED]? I'm not that well-versed in what makes an email address valid, but I'm sure more than a few valid email addresses will be rejected by the above requirements. If the string doesn't fit these requirements, then I send them back to the form to re-enter the address. The problem is that using the code below, the program complains even when the address *is* formatted properly. Any ideas how I could reformat the expression better? Yes. ## if(($email !=~ /\w+[@]\w+\.\w{2}/) or ($email !=~ /\w+[@]\w+\.\w{3}/) or ($email !=~ /\w+[@]\w+\.\w{4}/)) { print Improperly formatted e-mail address! Please use your browser\'s back ; print button and make sure the e-mail address is entered correctly. ; } ## First off, I'd recommend reading through the pattern matching section of the Camel Book (Programming Perl, by Larry Wall, et al, published by O'Reilly) again. There's a lot to learn. Now, a slightly better-working version of the code above: # CODE # unless($email =~ /^\w+(\.\w+)*\@\w+(\.\w+)*\.\w{2,4}\z/){ # error stuff } else{ # email-ok stuff } # END CODE # to examine that regex: ^\w+(\.\w+)*\@\w+(\.\w+)*\.\w{2,4}\z ^= the beginning of the string \w+ = one or more word chars (\.\w+)* = any number (any number includes zero) of sets of a dot and one or more word chars \@ = @ sign \w+ = one or more word chars (\.\w+)* = one or more word chars followed by any number of sets of a dot and one or more word chars \. = a dot \w{2,4} = one or more word chars \z = the end of the string I am NOT, however, saying that this regex necessarily matches all valid email addresses, or that it screens out all invalid ones. It doesn't. And nothing prevents users from entering something like [EMAIL PROTECTED]. hth, -- Michael -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex question
On Fri, 15 Jun 2001, Robert Watterson [EMAIL PROTECTED] wrote, Hi all, I have a line that has each field separated by commas. However, some of individual fields are double quoted strings and also have embedded commas in them. for example: Value1,Value2, blah,blah,blah,Value3,Value4,blah,Value5 When I use the split function using the split pattern of /,/ it obviously doesn't work. I believe what I want is to split on all commas when they are not followed by anything, then a double quote , then another comma. This seems like it should be a simple string to split into array values, but I just can't seem to get it to work. Anybody have any suggestions? use Text::ParseWords; { from perlfaq4: How can I split a [character] delimited string except when inside [character]? (Comma-separated files) } __END__ -- s::a::n-http(www.trabas.com)
Re: regex question
Robert Watterson wrote: : I have a line that has each field separated by commas. However, some of : individual fields are double quoted strings and also have embedded commas in : them. The Text::CSV_XS module will handle this. -- tdk