Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3923

Re: preg_match() oddities and question

From Sandman <mr@sandman.net>
Newsgroups comp.lang.php
Subject Re: preg_match() oddities and question
Date 2011-11-25 09:36 +0100
Message-ID <mr-1BAC45.09360625112011@News.Individual.NET> (permalink)
References (6 earlier) <1780410.D2KPVSPYKU@PointedEars.de> <mr-59B44E.09581623112011@News.Individual.NET> <4778042.ypaU67uLZW@PointedEars.de> <mr-8BFE1F.08204424112011@News.Individual.NET> <4ece3eb7$0$28723$a8266bb1@newsreader.readnews.com>

Show all headers | View raw


In article <4ece3eb7$0$28723$a8266bb1@newsreader.readnews.com>,
 Denis McMahon <denismfmcmahon@gmail.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]

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-22 12:21 +0100
  Re: preg_match() oddities and question The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 11:26 +0000
    Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-22 12:36 +0100
    Re: preg_match() oddities and question Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-22 07:22 -0500
  Re: preg_match() oddities and question tony@mountifield.org (Tony Mountifield) - 2011-11-22 11:47 +0000
    Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-22 13:12 +0100
  Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-22 13:30 +0100
    Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-22 13:55 +0100
      Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-22 17:56 +0100
        Re: preg_match() oddities and question The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 17:30 +0000
          Re: preg_match() oddities and question "Peter H. Coffin" <hellsop@ninehells.com> - 2011-11-22 17:20 -0600
            Re: preg_match() oddities and question The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 23:59 +0000
            Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-23 01:59 +0100
              Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-23 09:58 +0100
                Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-23 22:02 +0100
                Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-24 08:20 +0100
                Re: preg_match() oddities and question Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-24 12:55 +0000
                Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-25 09:36 +0100
                Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-24 22:41 +0100
                Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-25 09:26 +0100
                Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-25 15:44 +0100
                Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-25 16:34 +0100
                Re: preg_match() oddities and question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-25 23:23 +0100
              Re: preg_match() oddities and question The Natural Philosopher <tnp@invalid.invalid> - 2011-11-23 09:35 +0000
        Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-23 09:55 +0100
          Re: preg_match() oddities and question "Peter H. Coffin" <hellsop@ninehells.com> - 2011-11-23 07:53 -0600
            Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-23 19:01 +0100
              Re: preg_match() oddities and question The Natural Philosopher <tnp@invalid.invalid> - 2011-11-23 18:54 +0000
                Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-23 20:23 +0100
              Re: preg_match() oddities and question "Peter H. Coffin" <hellsop@ninehells.com> - 2011-11-23 12:58 -0600
                Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-24 08:28 +0100
  SOLVED: Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-25 10:32 +0100
    Re: SOLVED: Re: preg_match() oddities and question Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-25 18:55 -0500
      Re: SOLVED: Re: preg_match() oddities and question Sandman <mr@sandman.net> - 2011-11-26 11:21 +0100

csiph-web