Using grep to parse Canadian Postal Codes

This WebDNA talk-list message is from

2002


It keeps the original formatting.
numero = 45682
interpreted = N
texte = I am attempting to use WebCat's [grep] context to parse through a string to verify whether or not the string _could_ be a Canadian Postal code. I have already used grep to remove all characters except numbers and letters from a string, and am left with a 6 character string. I simply need to verify that the string is in the format of , such as A1A1A1.Here is the grep string I am using:[grep search=([^a-zA-Z][^0-9][^a-zA-Z][^0-9][^a-zA-Z][^0-9])&replace=\1_][zip_][/grep]I assume that it is simply running the entire string through each bracket in the search. My intention is to run the first character through the first bracket in the equation, the second through the second and so on. Here's what passes through the above equation:A1A1A1 (as it should) 111111 (this should fail) AAAAAA (this should also fail)What fails is:1A1A1A (as it should)If anyone can point me in the correct direction, I would be appreciative.Thanks,Dennis ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Using grep to parse Canadian Postal Codes (John Peacock 2002)
  2. Using grep to parse Canadian Postal Codes (Dennis J. Bonsall, Jr. 2002)
I am attempting to use WebCat's [grep] context to parse through a string to verify whether or not the string _could_ be a Canadian Postal code. I have already used grep to remove all characters except numbers and letters from a string, and am left with a 6 character string. I simply need to verify that the string is in the format of , such as A1A1A1.Here is the grep string I am using:[grep search=([^a-zA-Z][^0-9][^a-zA-Z][^0-9][^a-zA-Z][^0-9])&replace=\1_][zip_][/grep]I assume that it is simply running the entire string through each bracket in the search. My intention is to run the first character through the first bracket in the equation, the second through the second and so on. Here's what passes through the above equation:A1A1A1 (as it should) 111111 (this should fail) AAAAAA (this should also fail)What fails is:1A1A1A (as it should)If anyone can point me in the correct direction, I would be appreciative.Thanks,Dennis ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Dennis J. Bonsall, Jr.

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

DataBaseHelper Flawed (1997) Count how many items in a summ total (2003) Summing fields (1997) $Quit, $CloseDatabase corrections (1997) [shell] command seems flaky (2003) EmailProblem (2003) The Guru Speaks-Is That Really the Only Manuel? (1998) WebMerchant 3.0? (1998) [WebDNA] Error 500 with SUMM=T (2017) decrypt and summ problems (1999) Rounding Prices? (2000) PCS Frames (1997) OT: IP addres checking (2003) NT - Thanks and Taxes (1997) Public beta 2 for WebCatalog 4.0 is now available. (2000) [WebDNA] Connect to MS SQL (2013) Further tests with the infamous shipCost (1997) WebCat2b13MacPlugin - nested [xxx] contexts (1997) # of real domains on 1 web server (1997) F3 crashing server (1997)