移植preg_match_all去js正则表达式

时间:2013-10-30 22:12:26

标签: javascript php regex node.js

我正在尝试将PHP脚本移植到Nodejs,我完成了大部分工作,但我无法解决这个问题: 我得到了:

preg_match_all("@(==[^=]+==)(.+?(?=[^=]==[^=]|$))@s", $this->source, $paragraphs);

JS版本将如何? 我试过以下内容:

this.content.match(/(==[^=]+==)(.+?(?=[^=]==[^=]|$))/ig);

但结果很混乱。

如果我添加s标志,我会:

SyntaxError: Invalid flags supplied to RegExp constructor 'igs'
at new RegExp (<anonymous>)
at WikiParser.makeContent (D:\Smartly\application\models\parser.js:14:2)
at D:\Smartly\application\models\parser.js:63:10
at Request._callback (D:\Smartly\application\models\webworker.js:21:3)
at Request.self.callback (D:\Smartly\node_modules\request\request.js:129:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (D:\Smartly\node_modules\request\request.js:873:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (D:\Smartly\node_modules\request\request.js:824:12)
 at IncomingMessage.EventEmitter.emit (events.js:117:20)

0 个答案:

没有答案