December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 49 | Testing a Pattern with the Positive Lookbehind |
Suppose your task is to extract questions from a standardized test and store them in a database. The info you’re looking for always comes after a numbering system like “Question #5:”, but you want to extract the question text without its numbering.
The sticky flag wouldn’t be effective in this case because the length of characters in the numbering system varies between questions. For instance, one question may begin with “Question #9,” while another question may start with “Question #10” (for more on the sticky flag, see Recipe 44, Searching from a Specific Index with the y Flag).
You need a solution that allows you to match questions preceded by a “Question #n” without including ...
Read now
Unlock full access