Reputation: 469
My goal is match text inside parentheses (including them). This pattern works fine:/(\-?\(.*\))/gm
, although it doesn't work on multiple lines.
Any ideas how to also "catch"
(INDISTINCT ANNOUNCEMENT
OVER PA)
?
Here is the sample:
365
00:22:20,105 --> 00:22:21,772
(CLAMOURING)
366
00:22:21,774 --> 00:22:25,009
(INDISTINCT ANNOUNCEMENT
OVER PA)
367
00:22:55,340 --> 00:22:58,509
(INDISTINCT ANNOUNCEMENT
OVER PA)
368
00:23:10,655 --> 00:23:11,389
SARAH: Excuse me.
Upvotes: 1
Views: 55
Reputation: 7948
As mentioned in the comments, .
does not match the newline character. However, you can use [^)]
to match everything except )
, including newlines. e.g.
\([^)]*\)
Upvotes: 0
Reputation: 784878
You can use this regex to match content between (
and )
including newlines:
/\([\s\S]*?\)/g
In the absence of dotall flag in Javascript we use [\s\S]
to make it match newlines as well.
Upvotes: 2