我正在尝试将 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)