-3

I'd like to extend the syntax of Markdown with a simple pre-processing option.

When the text contains some words in squared brackets, but no parenthesis follows it:

Example text with [some reference] to show.

I'd like to extend it so that it becomes a self-referencing link:

Example text with [some reference](some-reference.html) to show.

Creating the result itself is something I can do on my own, but I have no idea, how can I match exactly only these expressions:

A word [and more] in the text.                    // this matches
A word [and more](stackoverflow.com) in the text. // this doesn't
Emma
  • 27,428
  • 11
  • 44
  • 69
Zoltán Schmidt
  • 1,286
  • 2
  • 28
  • 48

2 Answers2

2

\[(.*?)\] for your first, and for your 2nd \]\((.*?)\)

shadow2020
  • 1,315
  • 1
  • 8
  • 30
1

Something like this

\[([^\[\]]*)\](?!\([^()]*\))

https://regex101.com/r/64unOk/1