这是我想在 textarea 中匹配的内容:
@
+任何字符来执行自动完成操作,以便在@
调用时为用户查找并且在其旁边添加一个字符作为术语。
这是文本区域
<textarea></textarea>
这是js:
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);
现在我真的不知道在那里使用什么作为正则表达式,另外我不知道在那里使用它是否会有所帮助,因为它会在任何字符之前失去对 @ 的查找,因此以下字符串将返回 true :
@ mystring
因为我只需要找到:
@anycharacterhere
试过了
$(this).val().match(/^\+@\*+$/);