Solution Timeline

All versions (edits) of solutions to Regex to find match of 2 strings in order appear below in the order they were created. Comments that appear under revisions were those created when that particular revision was current.

To see the revision history of a single solution (with diffs), click on the solution number (ie. "#1") in the upper right corner of a solution revision below.

← Bounty Expand all edits

Hi Qdev,

If I understand correctly I think this is what you need:

Domain2\.com.*domain4\.com

The important bit is to have .* in between the nodes.

Test: https://regex101.com/r/vFoxoq/1

Hi Qdev,

If I understand correctly this is what you need:

Domain2\.com.*domain4\.com

The important bit is to have .* in between the nodes.

Test: https://regex101.com/r/vFoxoq/1

Hi Qdev,

If I understand correctly this is what you need:

Domain2\.com.*domain4\.com

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

Test: https://regex101.com/r/vFoxoq/1

Tipped

Vlad's solution should be sufficient.

But if you specifically want to return the whole line then this should do: https://regex101.com/r/MOr9MQ/1

And for strictly contiguous domain paths: https://regex101.com/r/9XJxjG/1

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

Winning solution