-2

我想在这个html中搜索这些字符串:

var c1Arr = new Array("","to fork","to fork","to fork","to fork","to fork","to fork","to fork","fork","fork","fork","fork","fork","fork","fork","fork","fork","fork-tongued","to fork off","to fork off","to fork out");
var c2Arr = new Array("","abbiegen","gabeln","abzweigen","aufspalten","sich gabeln","sich verzweigen","sich zwillen","Gabel","Gabelung","Abzweigung","Verzweigung","Aufspaltung","Abspaltung","Zwiesel","Gabel","Weggabelung","doppelzüngig","schräg abzweigen","schräg abbiegen","auszahlen");

我尝试过这样的事情:"^[c1Arr = new Array(][-\\.~:%_/?A-Za-z0-9]*[);]$"和一些变化,但这似乎不起作用。我阅读了有关如何构建正则表达式的教程,但这并没有太大帮助。

关于这些字符串的正则表达式看起来如何的任何想法?

4

1 回答 1

2

像这样的模式应该有效:

^var \w+ = new Array\(.*\);$

这将匹配字符串的开头(或多行模式下的行),后跟一个字面var量,后跟一个或多个“单词”字符,后跟一个字面量,= new Array(后跟零个或多个任意字符,后跟一个字面量);和字符串的结尾(或多行模式下的行)。

于 2013-08-29T19:27:26.007 回答