- <script language="JavaScript">
- var str1 = "求一个比较字符串处理功能";
- var str2 = "求两或三个比较字符串处理";
- var re = new RegExp("(?=.*?)[^" + str1 +"](?=.*?)|(?=.*?)[^" + str2 + "](?=.*?)", "g");
- var arr;
- while ((arr = re.exec(str1 + str2)) != null)
- {
- document.write(arr);
- }
- </script>
输出结果为:
一功能两或三