简体   繁体   中英

javascript regex to check for certain special characters in a url

I need a javascript regex to validate an streaming video url which starts with http or rtmp and whose length is <= 100 and which does not contain # % + , characters. I have come up with (http|rtmp)://.{10,93} for the first part and /^[^#%+,]+$/g for the second requirement.

I'm confused about combining these into a single regex. I'd appreciate any help in this direction. Thanks.

Could you not simply combine them like this?

^(http|rtmp)://[^#%+,]{10,93}$

Then you'd have http or rtmp followed by :// and between 10 and 93 characters which are outside of the ones you wish to exclude.

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