so I have this code:
const urlPattern = new RegExp(
"(https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}/?|www\\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}/?)"
)
I noticed that if I end the address with a punctuation mark, then the mark will get included in the address. Is there any way to exclude it? "Hello this is a string google.com, more stuff www.address.co." I want this to give ["Hello this is a string ", "google.com", ", more stuff ", "www.address.co", "."]
For now, I would like to assume that we are not submitting URLs with ending punctuation, but okay to have URLs with punctuation if it is followed up by another non punctuation non space character, like "www.google.com/blah.2stuff?here" is an okay url, but I would like "www.google.com/." to just return ["www.google.com/", "."] and the period to be kept separate. Do you have suggestions for how to do this?
[",'.]?
– emsimpson92 Jul 2 '18 at 17:54