I’m looking to remove duplicate phrases from any give string.
Example:
My_First_Post_My_First_Post.htm
Would have the phrase “My_First_Post” in there twice, thus becoming:
My_First_Post_.htm
Any easy way to do this?
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.
You can try regular expressions – careful about efficiency for sure, though:
It removes the first, longest, repeated sequence. To make it at least 10 characters, e.g., change the first group to:
To restrict the distance between characters to 2, e.g., change the second group to:
For 1 character, just put
(.??).