0

Tiny hint on regex which is excluding too much of a content.

Problem:

user created a few configurations for (docs, txt, xlsx) to protect and hide word(s). He used regex pattern: \{.*\} since he agreed with the client to insert the confidential text between curly braces.
The system however hides almost the whole file starting from the first opened curly brace to the last closed one. It does not stop at the end of sentence, line break. 
How to make the regex start over after each instance since there may be more than word to hide in the same sentence?

Solution:

regex used by the user is missing sign "?" since by adding this we tell it to repeat as few times as possible.

Hence the correct regex in this case is:

\{.*?\}

0 comments

Please sign in to leave a comment.