Closed Data-Meister closed 8 years ago
P.S. I've got some similar code for doing a substring replace
newString = originalStr.split( subStr ).join( replacementStr )
I could PR this in the same place. Or would it go better in another chapter?
And this is also faster: http://jsperf.com/occurrences-of-substring
But your commit is wrong.
message.split " a " .length - 1
would compile to
message.split(" a ".length - 1);
while we want
message.split(" a ").length - 1;
Thus, you want either of these:
message.split(" a ").length - 1
message
.split " a "
.length - 1
Cheers! I'll redo the PR with that corrected.
Shall I include the string replace code?
Shall I include the string replace code?
Wouldn't hurt! But check if there's a better section to place it into.
Why did this close? A pull request can be appended and modified by rebaseing and force pushing to the original branch.
This is a down side to using GitHub web interface over the Git command line tool.
Oh right, thanks for the tip sukima. I closed it with the intention of reverting then re committing. Will do this tonight hopefully.
Added benefit of not worrying about regex escaping.