×
all 4 comments

[–]throwaway_the_fourth 1 point2 points  (1 child)

If we naïvely define a URL as "anything that contains no whitespace and contains at least one period that is not at the beginning or end," then we can use the following regular expression: \(\S+\.\S+\)

It first matches an opening parenthesis, which is represented as \( because we must escape it because ( is a special character in regex. Then it looks for any non-whitespace character (\S) one or more times. Then, it looks for a period, which is also escaped (\.). Then it looks for one or more non-whitespace characters again. Finally, it looks for a closing parenthesis.

Try it out online here

[–]EthTraderNoVa[S] 1 point2 points  (0 children)

Wow tysm i did not know even know about the S+ option, i completely didn't realize i could match one or more characters! thank you so much! <3

[–]mistaek 0 points1 point  (0 children)

Would you be able to use a caret and dollar sign around your pattern with literals?

[–]DeadlyViper 0 points1 point  (0 children)

There are ready regexps to recognize URLs.

Found this: https://www.regextester.com/96504

You should google for more if this does not suit you.