Re: Re: Regex Help

From: Date: Tue, 27 Jan 2004 18:12:19 +0000
Subject: Re: Re: Regex Help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-175956@lists.php.net to get a copy of this message
Hi Ben, Your code works but If i remove the delimter [] which I gave so that you could capture the data which needs to be picked it doesnt work?. Any help? Karthikeyan B ----- Original Message ----- From: "Ben Ramsey" <br@benandliz.com> To: <php-general@lists.php.net>; "Karthikeyan" <karthikeyan.balasubramanian@aspiresys.com> Sent: Monday, January 26, 2004 11:56 PM Subject: [PHP] Re: Regex Help > Check the PHP manual for preg_match() > (http://us3.php.net/manual/en/function.preg-match.php). > > I did play around with it a little bit, and I think I've got a starting > point for you to work with. Try out this code and then play around with > it to get the results you need. $matches[2][0] will hold the full line > for Mayberry Mob. You could then just use the substr() function to pull > the data from that line. > > The code is, as follows: > > $subject = " > ===================================================== > NF [1/21/04] E Race 11 Grade B [5-16] Going F > > U Too Tipsy 60½ 2 1 1 1 1 1 1 ½ 30.46 4.40 Held Firm Inside > > Dream Away 62 8 2 3 2 3 2 ½ 30.51 17.90 Up For Plc Mdtk > > Pounce N Bounce 70 5 4 2 1 2 3 2 30.58 4.50 Held Show Inside > > Oneco Conor 67½ 7 8 4 5 4 4 2 30.60 6.90 Evenly Inside > > Krazy Kirk 70 4 3 6 7 5 5 5 30.79 * 1.90 Varied > Little Mdtrk > > Mayberry Mob 73½ 1 6 5 6 6 6 10 31.15 5.30 Never > Prominent Ins > > Jw Alley's Wish 60 3 7 8 9 7 7 10 31.17 6.50 No Factor Mdtrk > > Rooftop Comet 56 6 5 7 8 8 8 19 31.79 21.80 Never In It Mdtk > ======================================================== > "; > $pattern = "/\[(\d+\/\d+\/\d+|\d+\-\d+)\]|(Mayberry Mob.*)/"; > if (preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER)) { > print_r($matches); > } else { > echo "no match."; > } > > Hope that helps! > > > > Karthikeyan wrote: > > > Sorry last time I forgot to put subject on my mail. So here > > I am putting appropriate subject and sending it. > > > > Hi All, > > > > Just wondering if somebody can help me with this small regex search. > > The information I wanted to capture is the one in the Square Bracket. > > i.e Date : 1/21/04, Race Type: 5-16, Dog Position: 6(Mayberry Mob) > > > > ===================================================== > > NF [1/21/04] E Race 11 Grade B [5-16] Going F > > > > U Too Tipsy 60½ 2 1 1 1 1 1 1 ½ 30.46 4.40 Held Firm > > Inside > > > > Dream Away 62 8 2 3 2 3 2 ½ 30.51 17.90 Up For Plc Mdtk > > > > Pounce N Bounce 70 5 4 2 1 2 3 2 30.58 4.50 Held Show > > Inside > > > > Oneco Conor 67½ 7 8 4 5 4 4 2 30.60 6.90 Evenly Inside > > > > Krazy Kirk 70 4 3 6 7 5 5 5 30.79 * 1.90 Varied > > Little Mdtrk > > > > [Mayberry Mob] 73½ 1 6 5 6 6 6 10 31.15 5.30 Never > > Prominent Ins > > > > Jw Alley's Wish 60 3 7 8 9 7 7 10 31.17 6.50 No Factor Mdtrk > > > > Rooftop Comet 56 6 5 7 8 8 8 19 31.79 21.80 Never In It > > Mdtk > > ======================================================== > > > > Looking forward to hear some response. > > > > Have a great day. > > > > Karthikeyan B > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#175956) next »