Continuing the theme:
Regular expression, text replacement
Help modify the regular expression: (?<=1)\d(\d)\d(?=5)
so that you can get multiple internal expressions.
For example, the source text: 12345 is converted to 135 (as in the previous example). However, if it is necessary to perform a replacement for several internal expressions: 12342642845, then a match does not occur (the result should be 13685). Figures 2 and 4 can also be considered as reference points.
Is it possible to somehow achieve the universality of the expression to work on any number? You can of course create different expressions for different amounts of nested elements, but it seems to me that this is some kind of crutch.
[24]
for nothing - Mike\G
and\K
work? If so, then in global mode we change(1|(?!^)\G).*?\K[24](?=.*?5)
to nothing. - Mike^[^1]*(1\d*5)[^5]*$
). 2) From the result, delete all 2 and 4 (/[24]//
). In general, in order to understand how a regular example of one example should work is usually not enough. - andy.37