I have a bug in my wysiwyg editor. I have a box where I past a tweet url, and I must extract the ID to replace it with the embed code.
regex: {
twitter: /https?:\/\/twitter.com\/[a-zA-Z_]{1,20}\/status\/([0-9]*)/
}
if (str.match(this.opts.regex.twitter)) {
parsed = str.replace(this.opts.regex.twitter, '<blockquote class="twitter-tweet tw-align-center"><a href="https://twitter.com/x/status/$1">TWEET $1</a></blockquote>');
return parsed;
}
The bug is in my regex
/https?:\/\/twitter.com\/[a-zA-Z_]{1,20}\/status\/([0-9]*)/
If I take this url
https://twitter.com/howard3141/status/1330546000969273347
It doesn't work because 'howard3141' has some numbers inside.