当前位置:网站首页>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;
}
}

边栏推荐
- 【AGC】构建服务3-认证服务示例
- How do databases go to the enterprise cloud? Click to view the answer
- OSError: [Errno 28] No space left on device
- Differences and relationships among hyper convergence, software defined storage (SDS), distributed storage and server San
- Add / delete query of topic
- Appium automation test foundation - ADB shell command
- NTP of Prometheus monitoring_ exporter
- log4j
- 【JVM】G1垃圾回收器簡述
- 基于强化学习的股票量化交易Automated-Stock-Trading-Ensemble-Strategy
猜你喜欢

UAV project tracking record 83 -- PCB diagram completion

Applying applet container technology to IOT ecological construction

Difference between bow and cbow

Rider does not prompt after opening unity script

How do databases go to the enterprise cloud? Click to view the answer

Flume learning 4

9. cache optimization

Abstract classes and interfaces

IDC released the report on China's software defined storage and hyper convergence market in the fourth quarter of 2020, and smartx hyper convergence software ranked first in the financial industry

Installation and use
随机推荐
NFS shared services
C語言實現掃雷遊戲,附詳解及完整代碼
Theme Studio
云技能提升好伙伴,亚马逊云师兄今天正式营业
P. Summary of NP, NPC, NP hard and other issues
Principle and implementation of small program hand-held bullet screen (uni APP)
The present situation and challenge of the infrastructure of Yiwen parsing database
基于强化学习的股票量化交易Automated-Stock-Trading-Ensemble-Strategy
ABAP time function
Configuring MySQL for error reporting
【ARK UI】HarmonyOS ETS的启动页的实现
MySQL index and data storage structure foundation
[JVM] G1 garbage collector
Train an image classifier demo in pytorch [learning notes]
input限制输入
Redis docker master-slave mode and sentinel
Based on svelte3 X desktop UI component library svelte UI
Techtarget: Interpretation of the basic concept of super fusion cloud
MySQL optimization
log4j