Re: String Help
| From: | Herhuth, Ron | Date: | Thu, 06 Nov 2003 14:59:27 +0000 |
| Subject: | Re: String Help | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-22018@lists.php.net to get a copy of this message | ||
Thank You!
I appreciate all of the quick replies...you guys rock!
Ron
>From: Ignatius Reilly
>To: Herhuth, Ron; php-windows@lists.php.net
>Sent: 11/06/2003 9:21 AM
>This seems to work:
>
>$pattern = "/(\w+) (?:(?:\w\.|\(\w+\))) (\w+)/" ;
>$replacement = "\$1 \$2" ;
>
>//$string = "John D. Smith" ;
>$string = "Joanne (Taylor) Smith" ;
>
>echo preg_replace( $pattern, $replacement, $string ) ;
>
>HTH
>Ignatius
>_________________________
>----- Original Message -----
>From: "Herhuth, Ron" <Ron.Herhuth@tatumpartners.com>
>To: <php-windows@lists.php.net>
>Sent: Thursday, November 06, 2003 2:54 PM
>Subject: [PHP-WIN] String Help
>
>
>
>I have an instance where I am trying to remove a couple different string
>scenerios from a variable. I have spent some time with regEx but I'm not
>getting anywhere. I'm hoping someone could help me out here.
>
>Basically I have names that MAY contain middle initials which I need to
>remove:
>
>John D. Smith
>
>I need to strip the "D." so that I have only John Smith
>
>In addition I have a few instances where the name contains a secondary
>last name in parentheses that I need to remove:
>
>Joanne (Taylor) Smith
>
>I need to strip the Taylor so that I am left with Joanne Smith.
>
>If anybody could help me with this I would be very appreciative.
>
>Ron
>
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>