Home > Software design >  Replace a sequence of characters by anotyher one with regex
Replace a sequence of characters by anotyher one with regex

Time:10-22

I need to replace sequences (of various length) of characters by another character. I am working in Eclipse on xml files

For exemple -------- should be replaced by ********.

The replacement should be done only for sequences of at least 3 characters, not 1 or 2.

It is easy to find the matching sequences in regex for example with -{3,30} but I don't understand how to specify the replacement sequence.

CodePudding user response:

You can use

(?:\G(?!\A)|(?<!-)(?=-{3,30}(?!-)))-

See the enter image description here

  • Related