当前位置:网站首页>JS get the substring of the specified character position and the specified character position interval of the specified string [simple and detailed]
JS get the substring of the specified character position and the specified character position interval of the specified string [simple and detailed]
2022-06-30 10:07:00 【Boyun V】
Js Gets the specified character position of the specified string & Specifies the substring of the character position interval
1. Gets the location of the specified character
-- Sample string
var currentJsonRow.TRADE_TYPE='[1001] Bonded ';
grammar :
character string .substring(" Specify the characters ")
--- Example
currentJsonRow.TRADE_TYPE.substring("[")
result : '[1001] Bonded '
2. Get the substring of the specified character interval
The first one is : prevent IE Incompatible ( I really vomited in some factories ~! Just like IE… The right eyelid jumped again >…<)
For example, get the first [] The substring inside the brackets
Just look at the code below !( Very intuitive !!)
currentJsonRow.TRADE_TYPE.substring(currentJsonRow.TRADE_TYPE.indexOf("[")+1,currentJsonRow.TRADE_TYPE.indexOf("]"))
result : '1001'
The second kind : Regular expressions (YYDS!_ ok )
grammar :
/(?<=\[)(.+?)(?=\])/g
// Get the data in brackets
TRADE_TYPE_NUM = currentJsonRow.TRADE_TYPE.match(/(?<=\[)(.+?)(?=\])/g)[0];
[ The following business code , Don't look _^^]
// Add judgement -- Selected condition increase
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 == " All " || TRADE_TYPE_NUM == null || TRADE_TYPE_NUM == undefined) {
xAlert(">>^=^<<");
return;
}
}

边栏推荐
- How can we have high performance and simple agility in the enterprise cloud on oracle?
- JUL简介
- Machine learning note 9: prediction model optimization (to prevent under fitting and over fitting problems)
- Techtarget: Interpretation of the basic concept of super fusion cloud
- 浏览器复制的网址粘贴到文档是超链接
- [JVM] G1 garbage collector
- 2021-11-15
- GPT (improving language understanding generative pre training) paper notes
- 7.手机登陆功能开发
- 背课文记单词,读课文记单词,读文章记单词;40篇文章搞定3500词;71篇文章突破中考单词;15篇文章贯通四级词汇;15篇文章贯通六级词汇
猜你喜欢

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

Pytorch graduate warm LR installation
![[new book recommendation] DeNO web development](/img/86/27906ae378e597cf64bb2d760a9dff.png)
[new book recommendation] DeNO web development

Shenhe thermomagnetic: Super fusion dual active cluster solution for MES system

【AGC】构建服务3-认证服务示例

Flutter 中的 ValueNotifier 和 ValueListenableBuilder
![Train an image classifier demo in pytorch [learning notes]](/img/a5/fc14ee9dda1ec3e17b0ae2bda84d86.png)
Train an image classifier demo in pytorch [learning notes]

UAV project tracking record 83 -- PCB diagram completion

7.手机登陆功能开发

How to build a private cloud and create a hybrid cloud ecosystem?
随机推荐
About the split and join operations of strings
Datatabletomodellist entity class
Installing Oracle database process in windows2007 on VM
Bloom filter
train_de.py: error: argument --save_steps: invalid int value: ‘$[$[889580/128/4]*10/2]‘
Quick completion guide for mechanical arm (V): end effector
JWT expiration processing - single token scheme
Appium automation test foundation - ADB shell command
正则表达式基础
李沐《动手学习深度学习》d2lbook环境搭建
事件委托的使用与说明》
Differences and relationships among hyper convergence, software defined storage (SDS), distributed storage and server San
二极管如何工作?
Quick completion guide for manipulator (4): reducer of key components of manipulator
Upgrade log4j2 to 2.17.1 stepped pit
Flutter 中的 ValueNotifier 和 ValueListenableBuilder
Plan the IT technology route for the new year? Let's learn about Gartner infrastructure hype cycle
Applying applet container technology to IOT ecological construction
机器人系统动力学——惯性参数
[new book recommendation] DeNO web development