| View previous topic :: View next topic |
| Author |
Message |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Fri Feb 26, 2010 11:24 am Post subject: Identifying a Post Code |
|
|
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 |
|
 |
polyethene
Joined: 11 Aug 2004 Posts: 5248 Location: UK
|
Posted: Fri Feb 26, 2010 11:55 am Post subject: |
|
|
A very basic regex would be i)^[a-z]{1,2}\d\d?\s*\d[a-z]{2}$ _________________ GitHub • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Fri Feb 26, 2010 1:12 pm Post subject: |
|
|
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 |
|
 |
|