I have a string as :
var str = "str is str, 12str345 and ABCstrDEF";
I want capture all str
except ABCstrDEF
(str
surrounded by alphabetical characters)
Is it possible restrict alphabets with regex?
I have a string as :
var str = "str is str, 12str345 and ABCstrDEF";
I want capture all str
except ABCstrDEF
(str
surrounded by alphabetical characters)
Is it possible restrict alphabets with regex?
Go with
RegExp.quote = function(str) {
return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
};
var re = new RegExp("/\b[^a-zA-Z]*?" + RegExp.quote(str) + "[^a-zA-Z]*?\b/g");
alert(input.match(re));