var text = "mom and dad and baby";var pattern = /mom( and dad( and baby)?)?/gi;var matches = pattern.exec(text);alert(matches.index); // 0alert(matches.input); // "mom and dad and baby"alert(matches[0]); // "mom and dad and baby"alert(matches[1]); // " and dad and baby"aler t(matches[2]); // " and baby"
添加回答
举报
0/150
提交
取消