简体   繁体   English

RegExp查找soundcloud链接

[英]RegExp find soundcloud link

I'm trying my best to design a chat, and I want it to find soundcloud links and turn them into a player that can play the song. 我正在尽力设计一个聊天,我希望它能找到音云链接并将其转变为可以播放歌曲的播放器。 I know how to use their API for the player, but I can't get my RegExp to work. 我知道如何为播放器使用其API,但是我无法使RegExp正常工作。

My code: /https:\\/\\/soundcloud\\.com\\//gi only finds the soundcloud bit, but I also want it to find everything that comes after the slash until it hits whitespace. 我的代码:/ /https:\\/\\/soundcloud\\.com\\//gi : /https:\\/\\/soundcloud\\.com\\//gi只能找到音云位,但是我还希望它找到斜杠后的所有内容,直到遇到空格为止。

but I also want it to find everything that comes after the slash until it hits whitespace.

THen you ca use: 您可以使用:

/https?:\/\/soundcloud\.com\/\S*/gi

\\S* will match 0 or more non-space characters after https://soundcloud.com/ segment \\S*将在https://soundcloud.com/段之后匹配0个或多个非空格字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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