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


Groups > comp.lang.php > #3925

SOLVED: Re: preg_match() oddities and question

From Sandman <mr@sandman.net>
Newsgroups comp.lang.php
Subject SOLVED: Re: preg_match() oddities and question
Date 2011-11-25 10:32 +0100
Message-ID <mr-4B661B.10320625112011@News.Individual.NET> (permalink)
References <mr-5B96D1.12212022112011@News.Individual.NET>

Show all headers | View raw


In article <mr-5B96D1.12212022112011@News.Individual.NET>,
 Sandman <mr@sandman.net> wrote:

> So I have this regexp:
> 
> if (preg_match("/^(.*?)\s*(\d*?)\s*([A-Z,a-z,-]*?)$/", $search, $m)){
>     $streetname = uc_words($m[1]);
>     $streetnumber = trim($m[2]);
>     $streetletter = strtoupper($m[3]);
>     $search = trim($streetname . SPACE . $streetnumber . 
> $streetletter);
> }

It's funny how asking for help on the net works. Being an "oldie" I 
usually turn to IRC first, mostly because it's the most direct medium, 
knowledgable people may be online right there and then.

My next option usually is USENET, because I like the format and it's a 
lot like mail.

But I think I need to change all of that thinking. The last few years 
I've gotten the most effective help from sites such as stackoverflow, 
really.

So with my problem above, I didn't find any regexp wizard online on 
IRC so I came here asking it, using examples. That was two days ago. I 
recived plenty of responses, some really helpful, some not so much. I 
wouldn't expect immediate help and salvation from CLP really, but it's 
not totally uncommon for people to at least wanting to help in some 
way.

Since most replies were about the in-data or the database being 
incorrect in the first place, instead of just focusing on the actual 
question asked, I turned to stackoverflow. I posted a question today 
at 10 am

At 10:19am, I got a clean cut, no frills solution to my actual problem:

preg_match("/([a-zA-Z ]+) ?([0-9]+)? ?([a-zA-Z]+)?/"...)

That captures *all* my examples in the OP, and formats it *exactly* 
like I wanted to.

I'm not trying to disrespect anyone here, but there is a bit too much 
"elitism" and "You're doing it wrong" mentality here, and have always 
been. And some times it's justified, when pure newbies come here and 
asks how to create a guestbook in php. But it seems this mentality 
spills over to posters like me that aren't newbies but still need help.

I've been in this group for about ten years:

<http://groups.google.com/groups/profile?show=more&enc_user=YhtCLA4AAAB
X2xnmqiyRi8RpNstwOyTw&group=comp.lang.php>

But I'm proficient enough in PHP that I don't post all that often 
about needing help so I'm not a "regular" here and probably easily 
mistaken for a newbie.

See this as a pleed to think beyond your own preconceptions about the 
proficiency of a poster, you know the entire "innocent until proven 
guilty" :)

Or, just ignore it altogether. I got my solution so I'm happy either 
way :)


-- 
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