replace plain urls with links having the text truncated
I am using the answers from this question How to replace plain URLs with links? but I want the links to be truncated. For example, if the link is longer than 25 characters, I want to show https://stackover开发者_Go百科flow.com/questions/...
How can I call a slice or substring on a result from a regex?
You can do something like:
myString.replace(/(?=http://.....)(\S{,25})\S*/g, '<a href="$0">$1</a>');
Though this won't show the elipsis
精彩评论