I am trying to strip text and brackets for strings, for example:
'Location name (MA)' should become 'Location name', I can't use a simple str_replace() as the chars between the brackets could be any combination of 1 to 3 letters in caps from A-Z, anyone know how I can do this easily?
Many thanks
Finding and removing brackets and the text between brackets?
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
regular expressions seem like the best way to go
something like:
something like:
Code: Select all
preg_replace("#(\s?\([A-Z]{2,3}\))#",'');