I have a string like: Bruce A Johnson
I want it to be Bruce Johnson.
How do I remove the single A from the string with PHP? (all ‘words’ of only 1 character need to be removed)
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.
Something like this:
This says remove any single word character that has a word boundary on either side and optionally a trailing space.
Thus
b test a test foo cwill yieldtest test foo.If you might have some trailing punctuation (like
Bruce A. Johnson) you can get rid of the punctuation with this expression: