[PHP] Removing every thing between ( )
Hello, What would the regular expression be to remove all the text between ( ) $string = This is a (001 Test) and (002 Test); The numbers always change but the word stays the same Any help would be appreciated. Thank You Brian Paulson Sr. Web Developer [EMAIL PROTECTED] http://www.chieftain.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing every thing between ( )
On Wednesday, February 20, 2002, at 05:24 PM, Brian Paulson wrote: What would the regular expression be to remove all the text between ( ) $string = This is a (001 Test) and (002 Test); The numbers always change but the word stays the same preg_replace(/(\()\d{3,3} Test(\))/, \1\2, $string); That will leave your string looking like This is a () and (). Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Removing every thing between ( )
what do you have so far ? at least you need to 'replace', and I recommend perl style preg_replace() which is very powerfull. then you need an expressions that matches the '(001 Test)' part, how to do this can be found in the manual, however here's a small tip: /[0-9]+/ matches a series of one or more numbers bvr. On Wed, 20 Feb 2002 14:24:33 -0800, Brian Paulson wrote: Hello, What would the regular expression be to remove all the text between ( ) $string = This is a (001 Test) and (002 Test); The numbers always change but the word stays the same Any help would be appreciated. Thank You Brian Paulson Sr. Web Developer [EMAIL PROTECTED] http://www.chieftain.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Removing every thing between ( )
(not tested but...) something like: $string = ereg_replace(\([0-9]* Test\), , $string); if you want to keep the backets, then: $string = ereg_replace(\([0-9]* Test\), (), $string); HTH Martin -Original Message- From: bvr [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 21, 2002 9:30 AM To: Brian Paulson; php-general Subject: Re: [PHP] Removing every thing between ( ) what do you have so far ? at least you need to 'replace', and I recommend perl style preg_replace() which is very powerfull. then you need an expressions that matches the '(001 Test)' part, how to do this can be found in the manual, however here's a small tip: /[0-9]+/ matches a series of one or more numbers bvr. On Wed, 20 Feb 2002 14:24:33 -0800, Brian Paulson wrote: Hello, What would the regular expression be to remove all the text between ( ) $string = This is a (001 Test) and (002 Test); The numbers always change but the word stays the same Any help would be appreciated. Thank You Brian Paulson Sr. Web Developer [EMAIL PROTECTED] http://www.chieftain.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Removing every thing between ( )
Ok help me out here, isn't the point of this list to get help? How long is too long to work on a solution before ask for help? Brian -Original Message- From: bvr [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 2:33 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Removing every thing between ( ) whoops.. I see you allready got a cut and clean answer. now your lazy *and* lucky ;) try to figure it yourself next time, believe me it'll open up possibilities!! bvr. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Removing every thing between ( )
I believe I *am* helping you! bvr. On Wed, 20 Feb 2002 16:06:24 -0800, Brian Paulson wrote: Ok help me out here, isn't the point of this list to get help? How long is too long to work on a solution before ask for help? Brian -Original Message- From: bvr [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 2:33 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Removing every thing between ( ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Removing every thing between ( )
I agree - I think that if you've worked at something and feel that you're getting nowhere - then by all means ask. But I do feel that there have been some people that have posted to this list in past who have posted just to get someone else to do their code for them, without trying themselves. And no doubt there will be more in the furure... Just me 2c worth Martin -Original Message- From: Brian Paulson [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 21, 2002 11:06 AM To: 'bvr'; [EMAIL PROTECTED] Subject: RE: [PHP] Removing every thing between ( ) Ok help me out here, isn't the point of this list to get help? How long is too long to work on a solution before ask for help? Brian -Original Message- From: bvr [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 2:33 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Removing every thing between ( ) whoops.. I see you allready got a cut and clean answer. now your lazy *and* lucky ;) try to figure it yourself next time, believe me it'll open up possibilities!! bvr. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php