The reason you map to cont cont ItextI /cont is because the regex matches the first part of your cont pattern in the first "cont", then uses reluctant .*? to gobble up the space, the next space and the space preceding ItextI . When it reaches ItextI , it recognizes I as matching the next part of the pattern and continues the rest of the regular expression. As minitech writes, this is because the regular expression works from the beginning of the line and finds the earliest possible match.
If you can make assumptions about a space, you can write:
cont\s+I(.*?)I\s+/cont
This will match your example above.
source share