繁体   English   中英

JavaScript中的正则表达式,用于匹配给定的字符串

[英]Regular expression in JavaScript to match a given string

我有一个像下面的字符串

https://maps.googleapis.com/maps/api/streetview?channel=rdc-ldp-streetview&client=sourcemaps

如何检查返回的变量值是否与以下项匹配:

https://maps.googleapis.com/maps/api/streetview

ES6

str.startsWith('https://maps.googleapis.com/maps/api/streetview');

ES5

str.indexOf('https://maps.googleapis.com/maps/api/streetview') === 0

暂无
暂无

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

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