Saturday, 28 June 2014

String Replace and Search count using jquery/Javascript

Jquery or Javascript's Replace function does not provide facility to replace all occurrence of the search string it only search 1st occurrence and replace with other. To solve that issue, I have created function to find each occurrence All Replace from string . You can see in below image the function name solidReplace(Main string, Search string, Replace string).

Other function is the count. If you want to count the number of occurrence from the string. You can use function getCount() which is displaying in the image below. Syntax is (main string, search string).


No comments:

Post a Comment