在JavaScript中使用Regexp在多行字符串中查找两个句子之间的文本

时间:2015-08-30 18:01:25

标签: javascript regex node.js

我有以下文字来匹配正则表达式:

[dshow @ 000000000359bd00] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000000000359bd00]  "Logitech HD Webcam C270"
[dshow @ 000000000359bd00]     Alternative name "@device_pnp_\\?\usb#vid_046d&pid_0825&mi_00#7&316d5db0&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\{bbefb6c7-2fc4-4139-bb8b-a58bba724083}"
[dshow @ 000000000359bd00] DirectShow audio devices
[dshow @ 000000000359bd00]  "Microphone (HD Webcam C270)"
[dshow @ 000000000359bd00]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{2B89B488-1611-4574-B524-38A86F459087}"
[dshow @ 000000000359bd00]  "Microphone (Jabra UC VOICE 150a)"
[dshow @ 000000000359bd00]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{9EEC135F-7CA8-453F-8DB1-A8C8244EB2F1}"
dummy: Immediate exit requested

我写了一个正则表达式,它可以在RegExr here中使用。

但是当我在我的node.js应用程序中运行它时:

        var expr = new RegExp('DirectShow video devices \(some may be both video and audio devices\)[\s\S]*(.*)DirectShow audio devices', 'm');

        var responses = expr.exec(ffmpegOutput);

responses为空。我究竟做错了什么。谢谢。

0 个答案:

没有答案