I need a regular expression that will replace odd number of slashes with even number of slashes while leave the even number of slashes intact.
For Example:
- Test/123 –> Test//123
- Test//123 –> Test//123
- Test///123 –> Test//////123
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.
(?<!/)makes sure there are no slashes right before the match;/(//)*matches an odd number of slashes;(?!/)makes sure there are no slashes right after the match.The replacement string is
$0$0, which doubles up the matched slashes.I’ve tested this on your inputs, and it works exactly as per your spec.