Re: preg_match() oddities and question [message #176128 is a reply to message #176121] |
Fri, 25 November 2011 08:36 ![Go to previous message Go to previous message](/forum/theme/default/images/up.png) ![Go to next message Go to previous message](/forum/theme/default/images/down.png) |
Sandman
Messages: 32 Registered: August 2011
Karma:
|
Member |
|
|
In article <4ece3eb7$0$28723$a8266bb1(at)newsreader(dot)readnews(dot)com>,
Denis McMahon <denismfmcmahon(at)gmail(dot)com> wrote:
>> Well, I have been doing this for about ten years now, and recived tons
>> of feedback from my clients on things like this. When I say it's
>> inconvenient for the end user, it's not something I make up on the spot
>> to be obnoxious.
>
> It's a point that a lot of website UI designers overlook - what we think
> is the best and most obvious layout, and even "the way everyone does it",
> isn't always what the website user finds most user friendly.
Couldn't agree with you more here.
> As to the OPs problem, perhaps it needs a different approach:
(I am the OP, just for your information) :)
> Presumably for any given city you can obtain a list of valid streets?
No, not really. I have a database of addresses that the search should
match against. The relevant DB fields are these:
streetname "Stora gatan"
streetnumber "34"
streetletter "B"
address "Stora gatan 34B"
In-data variants I am concerned with are:
"Stora gatan"
"Stora gatan 34"
"Stora gatan 34b"
"Stora gatan 34 b"
And I need to build a regexp to extract the three parts from all these
in-data versions to match agains the "address" field (or, maybe even
against the three discrete fields).
This is where I'm stuck, since the regexp I use doesn't adequately
match the different versions of how the street letter is sent.
> Another option, and one that is becoming popular in some areas, might be
> to allow entry of the postcode, and then generate a drop down list,
> perhaps populated using an XMLHttpRequest, of addresses matching the
> postcode - this would require access to a copy of the relevant postcode
> database which might involve some cost, and of course you need to
> implement a mechanism for handling updates to that database.
I have all the post codes, but that's not helping me here. In short,
if the same address exists in two post codes, I would show both and
the user would select which one.
It's the address part that is my current problem. And splitting the
search box into three boxes (one for name, number and letter) is not a
desirable option for this application, unfortunately.
> I don't think you're ever going to parse a single line address entry with
> regex, because there are too many different formats that might get thrown
> at you.
Yeah, people here keep claiming that while ignoring that I am only
interested in capturing the above formats, that make out the vast vast
vast majority of all searches being done to this database. If I don't
match "34 Storgatan b", that's just fine by me. I have a very specific
case of searches that currently fail that I feel strongly could be
averted by a regular expression on the receiving end.
--
Sandman[.net]
|
|
|