August 11th, 2013, 07:57 AM
-
I want to match " @"+ any character javascript/jquery
Hi,
This is what I want to match inside of a textarea:
" @"+any character to perform an autocomplete operation to find for users when the @ is called and a character is added next to it as the term.
this is the textarea
Code:
<textarea></textarea>
this is the js:
Code:
function strpos (haystack, needle, offset) {
var i = (haystack + "").indexOf(needle, (offset || 0));
return i === -1 ? false : i;
}
var dauto=function(){
if(strpos($(this).val(),"@ "+reg_exhere)!==false){
alert("match found");
}
}
$("textarea").bind("keyup",dauto);
$("textarea").bind("keydown",dauto);
Now I really don't know what to use as the regular expression in there, plus I don't know if using it in there would help as it would loose the look up for the @ before any character so the following string would return true:
" @ mystring"
as whereas I only need to find:
" @anycharacterhere"
Thanks so much.
August 11th, 2013, 09:30 PM
-