2015-12-23 35 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]) 
相關問題