[英]With Javascript how would I search the first three letters in a string and see if they match “ABC”?
使用Javascript我如何搜索字符串中的前三個字母,看看它們是否匹配“ABC”? 謝謝
使用正則表達式:
str.match(/^ABC/);
或使用substring
方法:
str.substring(0, 3) == 'ABC';
if (/^ABC/.test(aString)) {
}
"ABCDEF".match(/^ABC/)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.