Hello, Could you please tell me why the following string replacement code is not working: function _striptext($document) { $search = array("'/pub\-.*$/;'",); $replace = array( "7185536717731935",); $text = preg_replace($search,$replace,$document); return $text; } Thanks for your time.
can you provide an example of what the value of document might be like? that might determine whether or not you need to use the values as arrays.
Hello, This is a script that was written by some else. $document was only used by the programmer when he wanted to strip something out of the output. Here are his notes: Input: $document document to strip. Always used for stripping strings out of the output. That's all the information I can give you.
Not sure what are you really looking for, but the script below seems to do what you want. function _striptext($document) { $replacement = "your replacement"; preg_match("/([pub-]+)\s*([a-zA-Z0-9]+)\s*[;]+/i", $document, $match); return $match[1].$replacement; } echo _striptext("pub-534sdf3423 ;"); PHP:
Thanks. For some reason nothing will work. There must be something in the script cancelling it out. Thanks anyway.