正则表达式文本匹配

时间:2014-02-08 07:43:02

标签: javascript regex

我希望将以下字符串格式与细分匹配到数组

var str = "A123456 some text F unwaned text blabla A123457 another text string F";

这样的事情

["A123456 some text F", "A123457 another text string F"]

1 个答案:

答案 0 :(得分:1)

var str = "A123456 some text F unwaned text blabla A123457 another text string F";
str.match(/A.*?F/g)
// => ["A123456 some text F", "A123457 another text string F"]