KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need the parse text with links in the following formats: [html title](http://www.htmlpage.com) http://www.htmlpage.com https://i.sstatic.net/rDDPu.jpg The output for those two strings would be: <a href='http://www.htmlpage.com'>html title</a> <a href='http://www.htmlpage.com'>http://www.htmlpage.com</a> <a href='https://i.sstatic.net/rDDPu.jpg'>https://i.sstatic.net/rDDPu.jpg</a> The string could include an arbitrary amount of these links, ie: [html title](http://www.htmlpage.com)[html title](http://www.htmlpage.com) [html title](http://www.htmlpage.com) [html title](http://www.htmlpage.com) [html title](http://www.htmlpage.com) wejwelfj http://www.htmlpage.com output: <a href='http://www.htmlpage.com'>html title</a><a href='http://www.htmlpage.com'>html title</a> <a href='http://www.htmlpage.com'>html title</a> <a href='http://www.htmlpage.com'>html title</a> <a href='http://www.htmlpage.com'>html title</a> wejwelfj <a href='http://www.htmlpage.com'>http://www.htmlpage.com</a> I have an extremely long function that does an alright job by passing over the string 3 times, but I can't successfully parse this string: [This](http://i.imgur.com/iIlhrEu.jpg) one got me crying first, then once the floodgates were opened [this](http://i.imgur.com/IwSNFVD.jpg) one did it again and [this](http://i.imgur.com/hxIwPKJ.jpg). Ugh, feels. Gotta go hug someone/something. For brevity, I'll post the regular expressions I've tried rather than the entire find/replace function: var matchArray2 = inString.match(/\[.*\]\(.*\)/g); for matching [*](*) , doesn't work because []()[]() is matched Really that's it, I guess. Once I make that match
Tags (comma-separated)
Save Edits
Cancel