当前位置:网站首页>Js獲取指定字符串指定字符比特置&指定字符比特置區間的子串【簡單詳細】
Js獲取指定字符串指定字符比特置&指定字符比特置區間的子串【簡單詳細】
2022-06-30 10:06:00 【泊雲V】
Js獲取指定字符串指定字符比特置&指定字符比特置區間的子串
1.獲取指定字符的比特置
--示例字符串
var currentJsonRow.TRADE_TYPE='[1001]保稅';
語法:
字符串.substring("指定字符")
---例子
currentJsonRow.TRADE_TYPE.substring("[")
結果: '[1001]保稅'
2.獲取指定字符區間的子串
第一種:防止IE不兼容使用的(有些工廠我真的吐了~!就喜歡IE…右眼皮又跳了>…<)
比如獲取首次[]中括號的裏面的子串
直接看下面的代碼吧!(直觀的很!!)
currentJsonRow.TRADE_TYPE.substring(currentJsonRow.TRADE_TYPE.indexOf("[")+1,currentJsonRow.TRADE_TYPE.indexOf("]"))
結果: '1001'
第二種:正則錶達式(YYDS!_好吧)
語法:
/(?<=\[)(.+?)(?=\])/g
//獲取中括號裏面的數據
TRADE_TYPE_NUM = currentJsonRow.TRADE_TYPE.match(/(?<=\[)(.+?)(?=\])/g)[0];
[下面的自己的業務代碼,不用看_^^]
//添加判斷--選擇的條件增加
if ($("[id$=hidShopID]").val() == "G181") {
if (currentJsonRow.TRADE_TYPE.match(/(?<=\[)(.+?)(?=\])/g) != null || currentJsonRow.TRADE_TYPE.match(/(?<=\[)(.+?)(?=\])/g) != undefined) {
TRADE_TYPE_NUM = currentJsonRow.TRADE_TYPE.match(/(?<=\[)(.+?)(?=\])/g)[0];
} else {
TRADE_TYPE_NUM = currentJsonRow.TRADE_TYPE.split('|')[0];
}
if (TRADE_TYPE_NUM == "全部" || TRADE_TYPE_NUM == null || TRADE_TYPE_NUM == undefined) {
xAlert(">>^=^<<");
return;
}
}

边栏推荐
- Configuring MySQL for error reporting
- ModuleNotFoundError: No module named ‘_swigfaiss‘
- 基于强化学习的股票量化交易Automated-Stock-Trading-Ensemble-Strategy
- How can we have high performance and simple agility in the enterprise cloud on oracle?
- Train an image classifier demo in pytorch [learning notes]
- 7.手机登陆功能开发
- [new book recommendation] DeNO web development
- Appium automation test foundation - ADB shell command
- C語言實現掃雷遊戲,附詳解及完整代碼
- 1. Basic configuration
猜你喜欢

About Jul
![[new book recommendation] cleaning data for effective data science](/img/42/1258694fc55a178a666391669a67ad.png)
[new book recommendation] cleaning data for effective data science
![[Ubuntu redis installation]](/img/66/d8054ae89007180b317641cf92d1cc.png)
[Ubuntu redis installation]

Eight sorts (I)

9. cache optimization

Rider does not prompt after opening unity script

云技能提升好伙伴,亚马逊云师兄今天正式营业

Valuenotifier and valuelistenablebuilder in fluent

Installing Oracle database process in windows2007 on VM

Theme Studio(主题工作室)
随机推荐
Financial private cloud infrastructure scheme evaluation (Architecture and storage)
About the split and join operations of strings
Forrester senior analyst: five important trends in the development of the hyper convergence market
NTP of Prometheus monitoring_ exporter
How does the diode work?
Quick completion guide for mechanical arm (V): end effector
Enterprise data center "cloud" transformation solution
C語言實現掃雷遊戲,附詳解及完整代碼
GPT (improving language understanding generative pre training) paper notes
[JVM] brief introduction to CMS
将小程序容器技术应用到物联网IoT生态建设中
Right click to open CMD (command line)
训练一个图像分类器demo in PyTorch【学习笔记】
Deberta (decoding enhanced Bert with distinguished attention)
UAV project tracking record 83 -- PCB diagram completion
机械臂速成小指南(五):末端执行器
How can we have high performance and simple agility in the enterprise cloud on oracle?
调试方法和技巧详解
Appium自动化测试基础 — adb shell 命令
qmlplugindump executable not found. It is required to generate the qmltypes file for VTK Qml