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

边栏推荐
- Rider does not prompt after opening unity script
- MySQL optimization
- Comparison problems encountered in recent study
- JWT expiration processing - single token scheme
- Theme Studio
- 无人机项目跟踪记录八十三---pcb图完成
- 力扣 428. 序列化和反序列化 N 叉树 DFS
- Add / delete query of topic
- 【JVM】G1垃圾回收器簡述
- Brève description du collecteur d'ordures G1
猜你喜欢

9.缓存优化

Techtarget: Interpretation of the basic concept of super fusion cloud

7. development of mobile login function

Abstract classes and interfaces

Dart development skills

机械臂速成小指南(四):机械臂关键部件之减速机

Difference between bow and cbow

MIT-6874-Deep Learning in the Life Sciences Week4

C語言實現掃雷遊戲,附詳解及完整代碼

Rider打开Unity脚本后没有提示
随机推荐
Stack Title: String decoding
Input limit input
Applying applet container technology to IOT ecological construction
Practice of super integration and transformation of core production business of public funds
训练一个图像分类器demo in PyTorch【学习笔记】
log4j
Bloom filter
OSError: [Errno 28] No space left on device
[ubuntu-mysql 8 installation and master-slave replication]
Some domestic image sources
Flume learning 4
Description of event object
Golang magic code
Machine learning note 9: prediction model optimization (to prevent under fitting and over fitting problems)
Flume learning 1
Add / delete query of topic
Valuenotifier and valuelistenablebuilder in fluent
Article content cannot be copied
Financial private cloud infrastructure scheme evaluation (Architecture and storage)
Force buckle 428 Serialize and deserialize n-tree DFS