Regex to find match of 2 strings in order
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

We have some data that looks like this (we call them domain paths) >>>

And> > >

We would like to query the above strings (domain paths) to find which ones have a specific couple of nodes in order. For example, find which ones had domain 1 before domain 4.

Ideally your regex and process each domain path looking for 2 specific domain nodes in a specific order. the two domains do not need to be contiguous but they do need to be in the right order

Can use for testing your regex

Could you please provide sample input and output? Will the input always be the string "domain"+number or it can be any string? is it case sensitive?
mashtullah 8 months ago
awarded to Wuddrum

Crowdsource coding tasks.

2 Solutions

Hi Qdev,

If I understand correctly this is what you need:


This is to test that is before
The important bit is to have .* in between the nodes.


hey we used Wuddrum's on this but i know you had a good solution base for it. sending tip
Qdev 8 months ago
Winning solution

Vlad's solution should be sufficient.

But if you specifically want to return the whole line then this should do:

And for strictly contiguous domain paths:

Remember to escape domains. e.g. should be domain1\.com when inserted into regex.

View Timeline