1

I want to use a regex that matches anything but when it finds a special character stop from matching.] I want to use this pattern \*\s*\[\[.* and when become this : ]] it stops matching.

For example it should match * [[anything here]] or * [[]] and it should not match the * [[anythng here]] anything ]] or should not match the * [[]]]]

I want to use this regex in Python for a Wikipedia bot.

the
  • 21,007
  • 11
  • 68
  • 101
Javad Yousefi
  • 2,250
  • 4
  • 35
  • 52

1 Answers1

2
\*\s*\[\[.*?\]\]

The ? after .* above makes the match reluctant/ungreedy. It will only match up until the first instance of ]] rather than the last.

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405