Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 从位于@和#符号之间的文本区域提取文本_Jquery_Regex_Textarea - Fatal编程技术网

Jquery 从位于@和#符号之间的文本区域提取文本

Jquery 从位于@和#符号之间的文本区域提取文本,jquery,regex,textarea,Jquery,Regex,Textarea,我想从位于@和#符号之间的textarea中提取文本,因为我使用下面的正则表达式 \B@(\w*)$/ 但是,当分隔符之间有空格时,我并没有得到预期的结果 比如说 "Welcome to the company @first name last name# We all wished." 我的输出应该是: first name last name 您可以使用匹配@和 var str=“欢迎来到公司@first name last name#我们都希望如此。”; var res=str.m

我想从位于@和#符号之间的textarea中提取文本,因为我使用下面的正则表达式

\B@(\w*)$/
但是,当分隔符之间有空格时,我并没有得到预期的结果

比如说

"Welcome to the company @first name last name# We all wished."
我的输出应该是:

first name last name
您可以使用匹配
@

var str=“欢迎来到公司@first name last name#我们都希望如此。”;
var res=str.match(/@(.*)#/)[1];
文件编写(res)试试这个

var regex = /\@(.*?)\#/;
var str="Welcome to the company @first name last name# We all wished.";
var matched = regex.exec(str);
console.log(matched[1])