简体   繁体   中英

Bot Framework Skype channel regular expressions not working

I built a bot using Bot Framework (node.js) with four connected channels (Messenger, Telegram, Skype and Web). At any moment the bot validates an inputted email address using a regular expression like this below:

/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i

It is working properly on all channels, except the Skype. Eg: gcfabri@gmail.com match with this regex but on Skype channel it doesn't happens.

According to GitHub user nwhitmont (Stack Overflow @nilsw ) on issue [Skype] Regular expression not working to find email address in chat message? #4024 :

Skype wraps email addresses in HTML tags, so you would need to adjust your RegEx accordingly.

On Skype channel you need to check for:

<a href="mailto:name@email.com">name@email.com</a>

I was also facing the same issue and resolved by using the following regular expression.

@"\b(?!mailto:)([\w-]+(.[\w-]+)@([a-z0-9-]+(.[a-z0-9-]+)?.[a-z]{2,6}|(\d{1,3}.){3}\d{1,3})(:\d{4})?)"

Skype is converting the user input email address to a HTML text eg ( <a href='mailto:someone@example.com'>someemail@mail.com</a> ). We need to find out the email from this.

For more detail, please refer. Regex for detecting emails in text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM