I am trying to capture user input in a textarea that might be a url (and similarly email) in any of the three formats -
Firstly, the second regex already works for the third format, so we only need to join the first and second ones.
The simple way to do this is to use the
| ("OR") character, like this:
The problem with this is that it mess the capturing groups. If the regex catches the first pattern, the url will be in a different capturing group (4th on my demo) than if it was captured by the second one (2nd group).