I struggle with Regular Expressions, but can usually decipher them. However...
For my chat room project, I need to parse text strings.
This involves converting any pasted URLs into clickable hyperlinks.
The RegExp I typically use for this task has been pieced together from various online examples and seems to be effective:
/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:~;@'#%&.=\]\[\*\$\!\?\/\,]+/g
Now, another aspect of my project requires embedding images by using the following syntax:
<img src="http://path/to/image" alt="alt" />
I attempted to modify the regular expression to ignore these image tags, like so:
/(?!src=")[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:~;@'#%&.=\]\[\*\$\!\?\/\,]+/g
Unfortunately, this modification did not yield the desired results. It's possible that my approach is incorrect or that there is an error in the expression.
One potential solution I considered was masking out 'src="http' before running the expression and then reintroducing it afterwards.
Before proceeding with this workaround, I wanted to reach out and see if anyone had any alternative suggestions to offer.
Thank you for your assistance.