August 5th, 2010, 04:46 PM
I have a name as follows
I wanted to write a regular expression to find the last dash (-) and remove until the dash. It should be like as below...
could somebody tell me how I can do that.
August 5th, 2010, 09:05 PM
The good thing is that you don't even need to use a regular expression.
$exp = explode('-', 'test-1-something');
echo $exp[count($exp) - 1]; // "something"
Soldiers, from the height of these pyramids forty centuries look down upon you.
▪ Napoleon, on the eve of the Battle of the Pyramids
August 6th, 2010, 08:25 AM
Thanks for your reply....
But I should have to use regular expression as I can use RE in my application or even xpath. So I'm looking to have RE so that I can implement in my application.
also there are bunch of stuff that i have with as I mentioned above..in other words
the source can be like ..
August 6th, 2010, 09:13 AM
A situation where the greedy dot-star is actually useful. Remove everything up to (and including) the last hyphen:
(presented in Perl style, but hopefully you get the picture).
August 6th, 2010, 10:34 AM
Thanks for your reply...
One thing that I forgot to mention is I can only use certain verbs in my application. so it got to use "replace first" "replaceall".