can we replace all hyphen with blank spaces but if space is followed by hypen and then another space it should not be removed, for example if i get “to-be-or-not – to-be” output should be “to be or not – to be” .is it possible
Share
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.
Assuming
$inputis your input string, try this:The regular expression means one non-space character
[^ ], followed by a hyphen and followed by another non-space character, and replace patterns means the first non-space character matched\\1, followed by a space, followed by the second non-space character matched\\2.