vendredi 20 février 2015

Remove '(' and text which follows from a string

Goal, to trim all text starting with the a left parenthesis '(' from a string. I've read through stack for the last hour, php.net, googled, I've tried using trim, ltrim, rtrim, strpos, preg_replace, etc. Everything that I have found so far has dealt with how to replace the text IF it is a know quantity - mine will vary.


Examples: Text i want to keep (All of this i want to remove) as well as this... Example 2: Text 2 keep (text to remove 123) Example 3: Keep Please (123remove)


What is the best way to sanitize this string? The text which follows the first paren will be alphanumeric (letters, numbers, possibly even Exclamation points, etc). The only constant is the first paren '(', anything after i want to trim away/remove.


I am of novice level, I am not yet dealing with classes or jQuery, etc. I wish to do this on the server.


Thank you for any help or guidance.


Aucun commentaire:

Enregistrer un commentaire