Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var replaceString = function(str, data, replaceWith,type) {
- var boundary = "",space ="";
- if(type === 'hashtag') {
- boundary = "#"
- } else if(type === "mentions") {
- space = " ";
- }
- data = data.replace(/([.?*+^$[]\(){}|-])/g, "\$&");
- //return str.replace(new RegExp("(?:^|\s)("+data+")(?!\s)", 'g')," "+replaceWith);
- return str.replace(new RegExp("(?:^|\b|\s)(" + data + ")(?!$\b\s"+boundary+")","g")," "+replaceWith+space);
- };
Add Comment
Please, Sign In to add comment