I'm working through a bunch of text in which I'm looking for the following strings:
The text under analysis is, for instance,
17 INT. BLOOM HOUSE - NIGHT 17
27 INT./EXT. BLOOM HOUSE - (PRESENT) DAY 27
Calls in php to, for instance,
preg_match("/^\w.*(INT\.\/EXT\.|EXT\.\/INT\.|EXT\.|INT\.)(.*)$/", $a_line, $matches);
and variants of that don't quite handle the greediness right (or so I think, anyway), and something gets left out, usually INT./EXT.
or EXT./INT.
items. Any advice? Thanks!
True, you need to use lazy dot matching with \w.*?
, but you can also optimize the pattern to shorten the alternation group like this:
/^\w.*?(INT\.(?:\/EXT\.)?|EXT\.(?:\/INT\.)?)(.*)$/
See the regex demo
Also, if you are processing the text as a whole, you will need a /m
multiline modifer.
Details:
^
- start of a string\w
- a word char.*?
- any 0+ chars other than line break chars as few as possible up to the first(INT\.(?:\/EXT\.)?|EXT\.(?:\/INT\.)?)
- Group 1 capturing either:
INT\.(?:\/EXT\.)?
- INT.
followed with optional /EXT.
substring|
- orEXT\.(?:\/INT\.)?
- EXT.
followed with optional /INT.
substring(.*)
- Group 2: any 0+ chars other than line break chars up to the...$
- end of string.Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I've only written very basic shortcodes without variables and am just not figuring out how to write one that allows someone to enter a variable to pull info from a specific post
I wanted to avoid asking this question since there are already a few threads on it, but I am still unable to find a solution for this after 5hrs and really need some help
i created my first project in laravel-- composer create-project laravel/laravel blogHow do i resume the project after maybe restarting my computer?
I'm playing something around with pthreads 31