当前位置:网站首页>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则不存在
边栏推荐
猜你喜欢

MySQL中字符串比较大小(日期字符串比较问题)

【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?

Phospholipid-Polyethylene Glycol-Aldehyde DSPE-PEG-Aldehyde DSPE-PEG-CHO MW: 5000

磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000

啃瓜记录第一天

Deveco studio 鸿蒙app访问网络详细过程(js)

@Accessors 注解详解

Deveco studio Hongmeng app access network detailed process (js)

redis进行持久化时,有新的写操作将如何解决——写时复制

nucleo stm32 h743 FREERTOS CUBE MX配置小记录
随机推荐
nucleo stm32 h743 FREERTOS CUBE MX配置小记录
docker 安装 sqlserver中的坑点
Chapter 10 Clustering
MySQL删除表数据 MySQL清空表命令 3种方法
【面试】失败的一次面试
mysql卸载详细教程
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
HCIP-第十一天-MPLS+BGP
解决glob()返回文件排序不一致问题&onnx本地按照安装方法
np.isnan()
querystring模块
「PHP基础知识」PHP中对象的使用
np.isnan ()
Dynamic proxy tool class
[Basic Tutorial of Remote Control Development 1] Crazy Shell Open Source Formation Drone-GPIO (Remote Control Indicator Light Control)
Detailed explanation of the usage of exists in mysql
MySQL中JOIN的用法
[Learning Records of Boxue Valley] Super summary, share with heart | Software Testing Interface Testing Basics
AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
ImportError: libGL.so.1: cannot open shared object file: No such file or directory