Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, such a regex function exists. Here is an example:

/(?<=STARTING_CHARACTERS)[\s\S]*?(?=STOPPING_CHARACTER)/

Replace "STARTINGCHARACTERS" with the set of characters at which you want to start and "STOPPINGCHARACTER" with the character at which you want to stop. This regex function will match any character, including line breaks, between the starting and stopping characters. The "?" after the "*" makes the matching non-greedy, meaning it will stop at the earliest stopping character it finds. The "(?<=...)" and "(?=...)" are positive look-behind and positive look-ahead assertions that ensure the starting and stopping characters are not included in the matched text.