This is what I would use.
(?<=(<pre>))(\w|\d|\n|[().,\-:;@#$%^&*\[\]"'+–/\/®°⁰!?{}|'~]| )+?(?=(</pre>))
Basically what he does:
(?<=(<pre>)) The selection should start with <pre>
(\w|\d|\n|[().,\-:;@#$%^&*\[\]"'+–/\/®°⁰!?{}|~]| ) This it’s just the regular expression that I want to apply. In this case, it selects a letter, number or newline or some special characters listed in square brackets in the example. The | symbol simply means “ OR ”.
+? Plus status symbols to select one or more of the above - the order does not matter. A question mark changes the default behavior from greedy to sloppy.
(?=(</pre>)) Selection must be added </pre>

Depending on your use case, you may need to add some modifiers, such as ( i or m )
- I'm case insensitive
- m - multiline search
Here I performed this search in Sublime Text, so I didn't have to use modifiers in my regex.
Javascript does not support rear view
The above example should work well with languages such as PHP, Perl, Java ... Javascript, however, does not support lookbehind, so we should forget about using (?<=(<pre>)) and look for some workaround Maybe just remove the first four characters from our result for each choice, as here Regex, match the text between the tags
Also look at the JAVASCRIPT REGEX documentation for non-capturing brackets.
DevWL Dec 01 '16 at 10:20 2016-12-01 10:20
source share