If data that is returned in the following way:
- The Matrix (1999)
- Shawshank Redemption (1994)
Just wondering whether there’s an easy way to remove the year and parentheses from the string e.g. remove (1999)?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As long as nested parenthesis aren’t an issue, you can simply use a regular expression:
subreplaces everything matched by the expression with the given string, in this case an empty string (nothing).\s*include any number of whitespace characters before the open parenthesis\(open parenthesis as a literal.+match one or more of any characters\)close parenthesis as a literal$match end of string – optional, you can leave this out if you want to remove parenthesized text anywhere in the string