2015-12-23 34 views

回答

1

您可以使用/@(.*?)#/@#

var str = "Welcome to the company @first name last name# We all wished."; 
 
var res = str.match(/@(.*)#/)[1]; 
 
document.write(res);
之间匹配任何

Regular expression visualization

1

试试这个

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