The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,466 other followers

Repeating the same expression multiple in RegEx search, and replace it only one time – via: Stack Overflow

Posted by jpluimers on 2015/07/29

I’m really really glad that Lucas Trzesniewski has answered this:

While most regex flavours have roughly a similar syntax for the basic features, there is not a clear standard as to the syntax of the replacement strings. Some tools use \1 for referencing strings, others use $1 and so on.

As you use Notepad++, you should know it uses the boost library for its regex implementation, and it uses the Boost-Extended format string for the replacement pattern.

In particular, the placeholder for the nth capture group is $n.

And my comment:

Thanks a lot for that. I found a bit more information about back references and capture groups in various libraries on

on my question:

I’m searching for groups of patterns that look like this:

[httpUrl](httpUrl "httpUrl")

and replace them with:


With a twist: all httpUrl must result in the same string and non-greedy.

I already got a start using RegExr: matching this pattern in a lazy manner and the twist:

\[(http:\/\/.*?)\]\(\1 "\1"\)

But I have a problem finding the replacement expression as this doesn’t work:


What am I missing here? (I hope it is soo simple that I will say duh).


via: Repeating the same expression multiple in RegEx search, and replace it only one time – Stack Overflow.

PS: The question is marked JavaScript as regex is used there very often, so it was easier to attract potential answers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: