AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Identifying a Post Code

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Fri Feb 26, 2010 11:24 am    Post subject: Identifying a Post Code Reply with quote

Hey guys,

I have an edit box where people can enter search criteria.

I would like my AHK script to be able to differentiate between search types.

So the script will get the text, and if it is a Post Code, it will perform a post code search.

A Post Code is a 6-7 alphanumeric code, with a space in it.

ie SP10 2AL or NW3 3PE

What is the best way of establishing whether the control text is a postcode, rather than a phone number, or plain text?

Any advice appreciated!
Back to top
View user's profile Send private message Visit poster's website
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Fri Feb 26, 2010 11:55 am    Post subject: Reply with quote

A very basic regex would be i)^[a-z]{1,2}\d\d?\s*\d[a-z]{2}$
_________________
GitHubScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Fri Feb 26, 2010 1:12 pm    Post subject: Reply with quote

How would I use this to identify a variable as a postcode?

So id need something like

If data = Postcode
{
Go do this
{

In my other checks, it runs through a list of criteria to determine what type of data it is.

ie

Code:
   if StrLen(clipSearch) = 9
   {
      StringLeft, searchPrefix, clipSearch, 2
            
      if searchPrefix = 21
         {
            SetSearch("TICKET","Ticket Number")
            Return
         }
      
      if searchPrefix = 10
         {
            SetSearch("ORDER","Order Number")
            Return
         }
....
....
....
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group