【发布时间】:2015-10-15 11:32:42
【问题描述】:
我想解析用户的输入并将所有笑脸“代码”替换为笑脸图像。当用户写一个 url 然后 http:// 和 https:// 的 :/ 被替换时,我遇到了一个问题。我用于 :/ 替换的当前正则表达式是“/://g”,我需要帮助更改它,因此它不会替换 :/ 如果它位于 http:// 或 https://
输入示例
请查看此链接http://stackoverflow.com,它可以帮助您:)。如果它没有帮助:/那么请使用https://www.google.com
应该解析输出
Please have a look at this link http://stackoverflow.com that could help you <img src="/smile.png"/>. If it does not help <img src="/sidesmile.png"/> then please use https://www.google.com
这是一个 regex101.com 示例:https://regex101.com/r/bB6vK2/1(如您所见,此处也选择并替换了 http:// 和 https://)
【问题讨论】:
标签: javascript regex parsing