Re: [SLUG] regex question
On Sun, Apr 13, 2008 at 09:16:59AM +1000, Alex Samad wrote: On Sun, Apr 13, 2008 at 08:39:17AM +1000, Alex Samad wrote: Hi I want to look at a config file that uses ; as comments, but I want to look at everything that is not a commented line so I tried grep -v '^\W*;' which sort of works, except it leaves me with blank lines now, how can I not show the blank lines adding to this I tried it in perl perl -nle 'print [$_] if ( ! m/^\s*;/)' sip.conf but it still prints out blank lines where it matches ? more delving into it I need something like this perl -nle 'next if ( /^\s*;/); print if length $_ 0' sip.conf I have to check if I have a blank line. I would have thought the next would read the next line ! (i realised i used \W instead of \s before) another question while we are on regex, how do I use [:space:] in grep and perl ? Alex -- Well, that's going to be up to the pundits and the people to make up their mind. I'll tell you what is a president for him, for example, talking about my record in the state of Texas. I mean, he's willing to say anything in order to convince people that I haven't had a good record in Texas. - George W. Bush 09/20/2000 on MSNBC signature.asc Description: Digital signature -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ ^ ([A-Za-z]([0-9]|[EMAIL PROTECTED]))# 1 alpha followed by 1 number or 1 punct | ([0-9]([A-Za-z]|[EMAIL PROTECTED])) # 1 number followed by 1 alpha or 1 punct | ([EMAIL PROTECTED]([A-Za-z]|[0-9])) # 1 punct followed by 1 alpha or 1 number $ All the best, Jacinta -- (`-''-/).___..--''`-._ | Jacinta Richardson | `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia| (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001| _..`--'_..-_/ /--'_.' ,' | [EMAIL PROTECTED] | (il),-'' (li),' ((!.-' | www.perltraining.com.au | -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Thanks everyone for some great help. I thought there might be a couple of regex gurus out there! Stuart On Nov 9, 2007 5:42 PM, Roger Barnes [EMAIL PROTECTED] wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ Is there a constraint requiring that this be done with a single regex? Depending on the context, there might be a number of more suitable programmatic approaches. For example, an unfinished, untested, inefficient, slapped together bash/grep approach might look like this, without getting tangled in regex syntax... password='a1#' hitcount=0 if $( echo $password | grep -q [A-Za-z] ); then echo Got alpha; let hitcount = $hitcount + 1; fi # Repeat for numeric and special chars # Check $hitcount == 2 or $hitcount = 2, depending on your requirements - Rog -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html -- Best regards Stuart Guthrie Director Polonious Pty Ltd (w) http://www.polonious.com.au (m) 0403 470 123 Polonious Support Numbers: Sydney: 61-2-9007-9842 Chicago: 1-312-212-3952 This above all: to thine ownself be true, And it must follow, as the night the day, Thou canst not then be false to any man. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
[SLUG] RegEx question
Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ Best regards Stuart Guthrie Director Polonious Pty Ltd (w) http://www.polonious.com.au (m) 0403 470 123 Polonious Support Numbers: Sydney: 61-2-9007-9842 Chicago: 1-312-212-3952 This above all: to thine ownself be true, And it must follow, as the night the day, Thou canst not then be false to any man. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ Thats not that great a specification :-). Can you give some examples of strings that you want to accept and others that you want to reject? Erik -- - Erik de Castro Lopo - The idea that Bill Gates has appeared like a knight in shining armour to lead all customers out of a mire of technological chaos neatly ignores the fact that it was he who, by peddling second-rate technology, led them into it in the first place. - Douglas Adams in Guardian, 25-Aug-95 -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] cheers rickw -- _ Rick Welykochy || Praxis Services The economy is a wholly owned subsidiary of the environment, not the reverse. -- Herman Daly -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
On Fri, Nov 09, 2007 at 04:48:20PM +1100, Rick Welykochy wrote: Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] close to what I was going to answer but it doesn't let you have 0A or #9 cheers rickw -- _ Rick Welykochy || Praxis Services The economy is a wholly owned subsidiary of the environment, not the reverse. -- Herman Daly -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html signature.asc Description: Digital signature -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
[EMAIL PROTECTED] wrote on 09/11/2007 04:48:20 PM: Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] Since I don't have a better answer, I should probably keep quiet, but there is a flaw in your regex: [EMAIL PROTECTED]:~$ perl my $var = 'a'; if ($var =~ /[EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED]/) { print True\n; } ^D True $var doesn't match the required 2 out of 3 characters, but still matches. Cheers, Scott -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
On Fri, 9 Nov 2007 15:39:54 +1100, Stuart Guthrie [EMAIL PROTECTED] said: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ A tool called txt2regex can help you build these - it keeps asking you questions, and show the regex corresponding to your answers. Also produces regexes for the languages you specify. http://txt2regex.sourceforge.net/screenshots.html -- Sonia Hamilton -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
On 09/11/07 15:39:54, Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ A crude but effective method is to delete one only instance of each regex and then compare the string lengths. For example, #!/bin/bash EXPRESSION0=ABCDefgh1234%$#@ EXPRESSION1=`echo $EXPRESSION0 | sed ' s/[A-Za-z]// s/[0-9]// s/[EMAIL PROTECTED]//'` echo ${#EXPRESSION0} echo ${#EXPRESSION1} HTH, Robert Thorsby Where a computer like the ENIAC is equipped with 18,000 vacuum tubes and weighs 30 tons, computers in the future may have only 1,000 vacuum tubes and weigh only 1 1/2 tons. -- Popular Mechanics, March 1949 -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Rick Welykochy wrote: Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] I'm not sure that would exclude 00 or 09 or some such combinationneeds and and logic in there somewhere and probably grouping Fil -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Rick Welykochy wrote: Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] Maybe something like [EMAIL PROTECTED](?(?=[A-Za-z])[EMAIL PROTECTED]|[EMAIL PROTECTED])$ Fil -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Phil Scarratt wrote: Rick Welykochy wrote: Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] Maybe something like [EMAIL PROTECTED](?(?=[A-Za-z])[EMAIL PROTECTED]|[EMAIL PROTECTED])$ Actually on second thought you may want to drop the first ?. It also depends on whether the characters specified in the above 3 conditions are the only allowable characters or not. Fil -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
Phil Scarratt wrote: Rick Welykochy wrote: Stuart Guthrie wrote: Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ [EMAIL PROTECTED]|[A-Za-z0-9]+|[EMAIL PROTECTED] Maybe something like [EMAIL PROTECTED](?(?=[A-Za-z])[EMAIL PROTECTED]|[EMAIL PROTECTED])$ Fil Cause I can't leave it alone: ^([A-Za-z]+|[0-9]+|[EMAIL PROTECTED])(?(?=[A-Za-z])[EMAIL PROTECTED]|[EMAIL PROTECTED]).*$ Fil -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] RegEx question
On Fri, 9 Nov 2007, Stuart Guthrie wrote: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ What's wrong with brute force? bool password_characters_good_choice(char *s) { int matches; matches = (match(abcdefghijklmnopqrstuvwxyz, s) + match(ABCDEFGHIJKLMNOPQRSTUVWXYZ, s) 0); matches += (match(0123456789, s) 0); matches += (match(%$#@, s) 0); return (matches 2); } where match(s1, s2) returns the number of occurances of the characters of s1 in s2. That's pretty easy to implement and is a prewritten function in a lot of languages. Cheers, Glen -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
RE: [SLUG] RegEx question
Not being a regex expert I was hoping someone could point me at a list, forum or just give me a pointer on how to achieve this: Field that must have 2 out of 3 of these: standard a-z/A-Z arabic numbers 0-9 special chars %$#@ Is there a constraint requiring that this be done with a single regex? Depending on the context, there might be a number of more suitable programmatic approaches. For example, an unfinished, untested, inefficient, slapped together bash/grep approach might look like this, without getting tangled in regex syntax... password='a1#' hitcount=0 if $( echo $password | grep -q [A-Za-z] ); then echo Got alpha; let hitcount = $hitcount + 1; fi # Repeat for numeric and special chars # Check $hitcount == 2 or $hitcount = 2, depending on your requirements - Rog -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
I missed the beginning of this discussion (I've just re-subscribed this week) but what's the reason that the original author wants this in a single RE? Malcolm V wrote: Ben de Luca (bedel) wrote: probably want to write a script to write the regex :) 10 points for the first code snippit that generates it !!! On 04/08/2004, at 3:43 PM, Alexander Samad wrote: On Wed, Aug 04, 2004 at 02:52:28PM +1000, Stuart Cooper wrote: Must match 3 out of 4 rules Must much at least 3 out of 4 rules I would imagine, the more oblique the password the better. 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation looking for 1 regex statement and perlre is the standard I think, Hmm, there are four cases for a match: 1,2,3 1,2,4 1,3,4 2,3,4 For each case there are six different orders the matches can be made in. eg for 1,2,3 1,2,3 1,3,2 2,1,3 2,3,1 3,1,2 3,2,1 This gives you a regex with 24 different matches OR'ed together ... o_O Only Dr Frankenstein would create such a monster. Cheers, Malcolm V. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
Ben de Luca (bedel) wrote: probably want to write a script to write the regex :) 10 points for the first code snippit that generates it !!! On 04/08/2004, at 3:43 PM, Alexander Samad wrote: On Wed, Aug 04, 2004 at 02:52:28PM +1000, Stuart Cooper wrote: Must match 3 out of 4 rules Must much at least 3 out of 4 rules I would imagine, the more oblique the password the better. 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation looking for 1 regex statement and perlre is the standard I think, Hmm, there are four cases for a match: 1,2,3 1,2,4 1,3,4 2,3,4 For each case there are six different orders the matches can be made in. eg for 1,2,3 1,2,3 1,3,2 2,1,3 2,3,1 3,1,2 3,2,1 This gives you a regex with 24 different matches OR'ed together ... o_O Only Dr Frankenstein would create such a monster. Cheers, Malcolm V. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
[SLUG] Regex question
Hi a friend has to implement in regex something along these lines of these rules to match against a string (password) Must match 3 out of 4 rules 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation Thanks Alex signature.asc Description: Digital signature -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
This one time, at band camp, Alexander Samad wrote: Hi a friend has to implement in regex something along these lines of these rules to match against a string (password) Must match 3 out of 4 rules 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation Firstly, you can't count in a regex, so you can't say once 3 of these match, then succeed. So really you want to test for each of these (with or without a regex) and then sum the results. You didn't say what language, so man perlre for some common regex syntax, and the re module from http://www.python.org/doc/lib/ for some python documentation. I can think of a python solution with about 6 lines in it, but I'd hate to deprive you of the joy of learning. Have fun! -- [EMAIL PROTECTED] http://spacepants.org/jaq.gpg -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
On Wed, Aug 04, 2004 at 02:24:09PM +1000, Jamie Wilkinson wrote: This one time, at band camp, Alexander Samad wrote: Hi a friend has to implement in regex something along these lines of these rules to match against a string (password) Must match 3 out of 4 rules 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation Firstly, you can't count in a regex, so you can't say once 3 of these match, then succeed. looking for 1 regex statement and perlre is the standard I think, the sort of thing I was thinking of but really ugly was (where [:1:] - set of chars that meets rule 1 above) ([:1:]+[:2:]+[:3:]+|[:1:]+[:2:]+[:4:]+|...) rather long and painful So really you want to test for each of these (with or without a regex) and then sum the results. You didn't say what language, so man perlre for some common regex syntax, and the re module from http://www.python.org/doc/lib/ for some python documentation. I can think of a python solution with about 6 lines in it, but I'd hate to deprive you of the joy of learning. Have fun! -- [EMAIL PROTECTED] http://spacepants.org/jaq.gpg -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html signature.asc Description: Digital signature -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
This one time, at band camp, Alexander Samad wrote: looking for 1 regex statement and perlre is the standard I think, the sort of thing I was thinking of but really ugly was (where [:1:] - set of chars that meets rule 1 above) ([:1:]+[:2:]+[:3:]+|[:1:]+[:2:]+[:4:]+|...) rather long and painful So you'd need each of the permutations for the 3 of 4 matches, (4P3, I think: 24 permutations) though you can compress each permutation into a single regex match with [[:upper:][:lower:][:digit:]]. That still ends up being (about 25 characters above, plus a bit of padding for extra grouping symbols) a regex of 600 characters or more, with the advantage that the structure of the regex gives no hints that it performs the above computation. Have fun! -- [EMAIL PROTECTED] http://spacepants.org/jaq.gpg -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
Must match 3 out of 4 rules Must much at least 3 out of 4 rules I would imagine, the more oblique the password the better. 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation looking for 1 regex statement and perlre is the standard I think, looking for 1 regex in this case is a bad thing to do. the simple and smart thing to do is to match all the four cases returning 1 or 0 for each one and then say # check supplied password matches at least 3 # of the criteria if ($matchUpper + $matchLower + $matchNumeric + $matchPunct = 3) { # new password OK } else { # new password bad, don't accept } Doing stuff in one confusing regex might look smart but keeping things simple and transparent is considerably smarter and more valuable. ### Some people, when confronted with a problem, think I know, Ill use regular expressions. Now they have two problems. --Jamie Zawinski, in comp.lang.emacs ### Stuart. Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
On Wed, Aug 04, 2004 at 02:52:28PM +1000, Stuart Cooper wrote: Must match 3 out of 4 rules Must much at least 3 out of 4 rules I would imagine, the more oblique the password the better. 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation looking for 1 regex statement and perlre is the standard I think, looking for 1 regex in this case is a bad thing to do. the simple and smart thing to do is to match all the four cases returning 1 or 0 for each one and then say # check supplied password matches at least 3 # of the criteria if ($matchUpper + $matchLower + $matchNumeric + $matchPunct = 3) { # new password OK } else { # new password bad, don't accept } Doing stuff in one confusing regex might look smart but keeping things simple and transparent is considerably smarter and more valuable. True but this is to be placed into a 4rd party program with no access to code! so has to be a regex ### Some people, when confronted with a problem, think ?I know, I?ll use regular expressions.? Now they have two problems. --Jamie Zawinski, in comp.lang.emacs ### Stuart. Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com signature.asc Description: Digital signature -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
Re: [SLUG] Regex question
probably want to write a script to write the regex :) 10 points for the first code snippit that generates it !!! On 04/08/2004, at 3:43 PM, Alexander Samad wrote: On Wed, Aug 04, 2004 at 02:52:28PM +1000, Stuart Cooper wrote: Must match 3 out of 4 rules Must much at least 3 out of 4 rules I would imagine, the more oblique the password the better. 1) Contain 1 or more Uppercase char 2) Contain 1 or more Lowercase char 3) Contain 1 or more numeric 4) Contain 1 or more punctuation looking for 1 regex statement and perlre is the standard I think, looking for 1 regex in this case is a bad thing to do. the simple and smart thing to do is to match all the four cases returning 1 or 0 for each one and then say # check supplied password matches at least 3 # of the criteria if ($matchUpper + $matchLower + $matchNumeric + $matchPunct = 3) { # new password OK } else { # new password bad, don't accept } Doing stuff in one confusing regex might look smart but keeping things simple and transparent is considerably smarter and more valuable. True but this is to be placed into a 4rd party program with no access to code! so has to be a regex ### Some people, when confronted with a problem, think ?I know, I?ll use regular expressions.? Now they have two problems. --Jamie Zawinski, in comp.lang.emacs ### Stuart. Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
RE: [SLUG] Regex Question
I think the one lesson we should have learned from the y2k hoola is that date's in general are a pain to handle and are much more complicated than they look. The best way is to find a date class and have it parse the date for you because: 1. The time spent grepping through the documentation and reading it is less than time spent coding it. 2. The code you grab out of a library has most likely been used at least thousands of times and thus is thousands time less likely to contain bugs/flaws. 3. It will make your code more readable to the person who has to look at it after you. Cheers, Dave. -- David Zverina Alt Key Pty. Ltd. http://www.altkey.com PO Box 3121, Parramatta, 2124, Australia -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jason Rennie Sent: Wednesday, 10 January 2001 14:16 To: [EMAIL PROTECTED] Subject: [SLUG] Regex Question Hi all, Given the number of Regex guru's on this list. I'm using the gnu c++ string lib which apparently will accept regex's for its string.contains() function call. I need to parse a date of the form DD/MM/ and I need to check that is looks exactly like that. Nothing but intergers and slashes in the right places. Any ideas ? Jason -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://slug.org.au/lists/listinfo/slug -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://slug.org.au/lists/listinfo/slug
RE: [SLUG] Regex Question
than time spent coding it. 2. The code you grab out of a library has most likely been used at least thousands of times and thus is thousands time less likely to contain bugs/flaws. 3. It will make your code more readable to the person who has to look at it after you. But i need it for a 1 off assignment at uni, and the regex that john suggests seems to be everything but y10K proof. Jason -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://slug.org.au/lists/listinfo/slug
[SLUG] Regex Question
Hi all, Given the number of Regex guru's on this list. I'm using the gnu c++ string lib which apparently will accept regex's for its string.contains() function call. I need to parse a date of the form DD/MM/ and I need to check that is looks exactly like that. Nothing but intergers and slashes in the right places. Any ideas ? Jason -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://slug.org.au/lists/listinfo/slug
Re: [SLUG] Regex Question
On Wed, Jan 10, 2001 at 02:16:03PM +1100, Jason Rennie wrote: Hi all, Given the number of Regex guru's on this list. I'm using the gnu c++ string lib which apparently will accept regex's for its string.contains() function call. I need to parse a date of the form DD/MM/ ^[0-3][0-9]\/[01][0-9]\/[0-9][0-9][0-9][0-9]$ and I need to check that is looks exactly like that. Nothing but intergers and slashes in the right places. Any ideas ? Jason -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://slug.org.au/lists/listinfo/slug -- John Ferlito Senior Engineer - Bulletproof Networks ph: +61 (0) 410 519 382 http://www.bulletproof.net.au/ -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://slug.org.au/lists/listinfo/slug