How can i replace Hypen’s inside a string, but ignore hypens preceded by a slash eg: “Just-Testing-A-String-\–But i want to leave this hypen”
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.
If you want to keep only one hyphen that follows the \, then you can use regex
UPDATE:
Actually I don’t believe that it is possible to create such a rexeg, because in this case you would have to do two replacements: one is for
and another one is for
so you need to run two replacements. The only thing I can think of is if you OK with replacing ‘\’ with ‘ ‘ also. Then you can use the following regex