当前位置:网站首页>js 取字符串中某位置某特征的值,如华为(Huawei)=>华为
js 取字符串中某位置某特征的值,如华为(Huawei)=>华为
2022-08-02 03:22:00 【suzhiwei_boke】
let brandName = ' '
if (item.name.indexOf('(') !== -1) {
const index = item.name.lastIndexOf('\(') // 判断名字是否有(),有则去掉
brandName = item.name.substring(0, index)
} else {
brandName = item.name
}
考察两个知识点,字符串查找 indexOf() 值为-1则不存在
边栏推荐
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/yolov5-5.0/models/commo
- Debian 10 NTP Service Configuration
- 跨域问题解决
- 一个结构体 = 另一个结构体(同类型结构体之间可直接赋值操作)
- HCIP-第十天-BGP综合实验
- 利用 nucleo stm32 f767zi 进行USART+DMA+PWM输入模式 CUBE配置
- MySQL分组后排序
- About cross-domain issues
- ModuleNotFoundError No module named ‘xxx‘可能的解决方案大全
- JJWT tool class
猜你喜欢
MySQL分区表详解
Problems when yolov5 calls ip camera
Phospholipid-polyethylene glycol-azide, DSPE-PEG-Azide, DSPE-PEG-N3, MW: 5000
离线数仓-用户行为采集
About cross-domain issues
[详解C语言]一文带你玩转C语言小游戏---扫雷
Deveco studio Hongmeng app access network detailed process (js)
DSPE-PEG-Silane,DSPE-PEG-SIL,磷脂-聚乙二醇-硅烷修饰活性基团
HCIP-第十一天-MPLS+BGP
C语言 0长度数组/柔性数组
随机推荐
啃瓜记录第一天
Redis的集群模式
一个结构体 = 另一个结构体(同类型结构体之间可直接赋值操作)
【装机】老毛桃的安装及使用
Monaco Editor 的基本用法
docker 安装 sqlserver中的坑点
Redis simple study notes
@Autowired与@Resource区别
解决glob()返回文件排序不一致问题&onnx本地按照安装方法
Redis安装,基本命令,持久化方式,集群
C语言 结构体定义方法
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
磷脂-聚乙二醇-酰肼,DSPE-PEG-Hydrazide,DSPE-PEG-HZ,MW:5000
ssm various configuration templates
C语言的变长数组
【面试】失败的一次面试
Debian 10 NTP Service Configuration
AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
【 application 】 life many years of operations, what turned scored 12 k + annual bonus salary?
parser = argparse.ArgumentParser()解析