You can use regular expression to capture the groups
const regex = /^(.{3})(.{2})(\D+)(.{16})(.{6})(.{6})(\d+)(.{3})$/
const str = '48001MCAbastillas2200800046300017100518110555130000123'
const values = str.match(regex)
console.log(values)
var input = '48001MCAbastillas2200800046300017100518110555130000123';
// match parts with regex
var match = input.match(/^(.{3})(.{2})([a-zA-Z]+)(.{16})(.{6})(.{6})(\d+)(.{3})$/);
// remove first element (full matching input)
match.shift();
// build output
var output = match.join(' | ');
console.log(output);
const test = [
'48001MCAbastillas2200800046300017100518110555130000123',
'48001MCAbasti2200800046300017100518110555130000123',
'48001MCAbastillasXYZ2200800046300017100518110555130000123',
'48001MCAbastillas2200800046300017100518110555130000999123',
'48001MCAbastillas2200800046300017100518110555130123',
'48001MCAbastillasXYZ2200800046300017100518110555130000999123',
'48001MCAbasti220080004630001710051811055513123'
]
const p = /(?<name>\D+)(\d{28})(?<amount>\d+)(\d{3}$)/
console.log (test.map (s => s.match (p).groups))
I've figured out how to create an object based on an array, now I'm trying to understand how to build an array back from that object. with the object { social: { children: { ...
I've figured out how to create an object based on an array, now I'm trying to understand how to build an array back from that object. with the object { social: { children: { ...
Suppose I have this string: let string = '<h1 style="lots of class"> </h1><h2> <p style="bunch of class"> </p> <p style="bunch of class"> </p></h2>'; ...
Suppose I have this string: let string = '<h1 style="lots of class"> </h1><h2> <p style="bunch of class"> </p> <p style="bunch of class"> </p></h2>'; ...
i need to check whether the date is between minDate and maxDate. but when i try to compare with minDate, i should get valid as false but am getting true.. let minDate = "27-05-2019"; ...
i need to check whether the date is between minDate and maxDate. but when i try to compare with minDate, i should get valid as false but am getting true.. let minDate = "27-05-2019"; ...
The following snippet is from "Example 5" from this thread on JS and closure. Alternatively, this other thread sort of gets at what I'm curious about. function buildList(list) { var result = []; ...
The following snippet is from "Example 5" from this thread on JS and closure. Alternatively, this other thread sort of gets at what I'm curious about. function buildList(list) { var result = []; ...