Given the string s1, return the string s2 with the target characters removed.
For example, given
s1 = 'the main event'
your code would return
s2 = 'the event'
Note the 2 spaces between "main" and "event" Only the four letters in the word "main" were deleted.
This problem is fantastic to improve his knowledge with regular expressions!
I have rescored the leading problem to make sure its not zero
I learned so much about the regexp and strjoin functions because of this problem. Thank you!
I agree... This problem improved my knowledge of regexp. Although my code is running well in my computer but not here. I'm using R2015a. Can anyone please help ! Thank you
Did it in two steps, so many functionality in regexp that I discovered for myself today.. )
nice problem..really nic
I think i should learn regular expression
wow
Hi all, I just can't find out why the assertion fails. All works well on my MALTAB but not here. Both codes (commented and not) remove only the words which end with 'ain' and leave the two spaces but still the assertions here has failed.
This passes in R2017b, yet fails here. Why?
Actually this code won't pass the Test Suite on any version of MATLAB. The misunderstanding is caused by rendering of HTML text on Cody, which means that double-spaces are not _displayed_ in the Test Suite's solutions; nevertheless, the correct solutions do contain double spaces, as you can confirm by viewing the HTML source, and as also explained in the problem statement. Your code is removing some spaces. I'm sure you can fix it now, with this knowledge.
Thanks for clarifying. I appreciate it.
Probably not what i was supposed to do, but hey it works.
I think something is broken, I passed it the s2 given in the test suite and the assertion still fails.
Took me nearly one hour to solve (though not complete,for just "ain,it is wrong).But I think it's great.I recently learn regular expressions.
regexprep(s1, '(\w*)ain', '')
not working pls help me
Hi harish, so the if you see the regexprep documentation, it will tell you when you execute, it will remove every word which contains the letters ain in the expression. You can verify this on your system. To solve this, you need to look for a way to use regexprep such that it only looks for the letters in the end of the word.
I have to admit that this solution is not general
615 Solvers
Back to basics 4 - Search Path
280 Solvers
223 Solvers
Output any real number that is neither positive nor negative
252 Solvers
325 Solvers