Input: ball ball code
Output should be: ball code
Input: awycodeawy
Output should be: awycode
I tried these, but didn’t work:
$q = preg_replace("/\s(\w+\s)\1/i", "$1", $q);
$q = preg_replace("/s(w+s)1/i", "$1", $q);
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.
Here is positive lookahead base attempt on regex based solution to OP’s problem.
OUTPUT
As you can for the input
'awycodeawy'it makes it to'codeawy'instead of'awycode'. The reason is that it is possible to find avariable length lookaheadsomething which is not possible forlookbehind.