So, slowly learning more and more PHP... once and a while coming across stuff that talks about Regular Expressions... and every time I've seen it, or gone to try to learn it, its just confused the hell out of me. For some reason I just cant rap my mind around it.
So Im coming here for help. I have colon separated paired values... and I want to be able to remove one of the pairs, from somewhere in the string.
These values are of a 'Player' and there 'Character'. Such that:
Jaryth:Tarrax:James:Alex:Raymond:Kid
Jaryth, James and Raymond are all 'Players' and Tarrax, Alex and Kid are their respective 'Characters'.
Basicaly what Im looking to do, is to have the above string, go in, remove one of the Player:Character pairs, and return the modifed string.
Im guessing its going to look SOMETHING like the following:
PHP Code:
function pullout($string,$out){ preg_match($String, ^%**&^!%^><^^<>^ $out); } $string = "Jaryth:Tarrax:James:Alex:Raymond:Kid"; $out = "James:Alex" $result = pullout($string,$out); //This would... somehow return the string "Jaryth:Tarrax:Raymond:Kid"
And I just cannot grasp Regular Expressions for the life of me... (hence the randomness). So would anyone be able to help me by creating the expression I would need?
__________________
Please login or register to view this content. Registration is FREE My personal website
-Jaryth (UID590)
Last edited by Jaryth000; 03-06-2009 at 05:13 AM..
Reason: changes the randomness so it did not break the Highlightin.
|