Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Sandman Newsgroups: comp.lang.php Subject: Re: preg_match() oddities and question Date: Fri, 25 Nov 2011 09:36:06 +0100 Lines: 73 Message-ID: References: <1670168.aK4W3vaeNJ@PointedEars.de> <3004614.SPkdTlGXAF@PointedEars.de> <1780410.D2KPVSPYKU@PointedEars.de> <4778042.ypaU67uLZW@PointedEars.de> <4ece3eb7$0$28723$a8266bb1@newsreader.readnews.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net vGkHFUA9xqYutx0sVLrL4wkLIlea5EFsC1q82SW+mKx4fSx5Y= X-Orig-Path: mr Cancel-Lock: sha1:sBX8xmpTN7QSzYWw0hINHh12aT4= User-Agent: MT-NewsWatcher/3.5.2 (Intel Mac OS X) X-Face: $@,Vfa$,)%=Qa7L]y)&oZj_\EiHc}}Af0Bei"4a_%)"c6TQ+P/:53>;PNGuWUmkqyeN-qM65foJ[;T_(k;>]&G\T4Lhm:2 ujye2_,iUJFE;NZn>y;.|-hl7g~bIOF1qG\o, Denis McMahon 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]