[PHP] ereg usage
Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. Many thanks Peter Gumbrell [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg usage
At 16:18 16.02.2003, Peter Gumbrell said: [snip] Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. [snip] You're missing the -1 part in your expression: ^ Your string begins [A-H]* with no or more letters from A to H ([0-9]+)followed by one or more digits (grouped) -followed by a dash $ and the end or the string Your pattern would match C12-, but not C12-1. If you only need the C12, your pattern should look something like '^([A-H]*[0-9]+)-' to return the complete letter/digit sequence at the beginning of the string, up to (but not including) the dash. Omitting the '$' (string end) character allows for anything after the dash. -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg usage
The problem is that it's looking for hyphen, - , immediately preceeding the end. Remove the $. - Original Message - From: Peter Gumbrell [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Sunday, February 16, 2003 9:18 AM Subject: [PHP] ereg usage Could someone please tell me why this code is not working: ereg ('^[A-H]*([0-9]+)-$', $rank, $matches); $workshop_ID = $matches[1][2}; where $rank is something like C12-1 and I just need the C12 part. Many thanks Peter Gumbrell [EMAIL PROTECTED] -- 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