skip to Main Content

String processing in Javascript using Array

Here is the input that should be converted to JSON format as given below. '{RS0004036}:{1;2}:{0000003AB;0000003BC}_{RS0004036}:{0;3}:{0000003DE;0000003FG}_{RS0004036}:{3;3}:{0000003HI;0000003JK}' Target JSON should be like this. The code should read the above input, will create a JSON return string as follows. The returning JSON will…

VIEW QUESTION

Convert the text input file to JSON in Python

I am using python to convert the text input file to json. My Code: import json import re filename = "text.txt" text = {} pattern = re.compile(r's*([^=t]+)s*=s*(.*)') with open(filename, encoding='utf8') as file: for line in file: match = pattern.match(line.strip()) if…

VIEW QUESTION

Javascript – i suppose to recive random names and uppercase their first letter but when i put empty space in .split(' ') , my code breakdown

const capitalizeName = function (name) { const names = name.split(` `); const uppercasedName = []; for (const n of names) { //uppercasedName.push(n[0].toUpperCase() + n.slice(1)); uppercasedName.push(n.replace(n[0], n[0].toUpperCase())); } console.log(uppercasedName.join('')); }; capitalizeName('jessica ann smith davis '); console shows the problem lies in…

VIEW QUESTION

Javascript replace regex wildcard with dynamic text

I need to extract text but some parts are dynamic and change This is my var htts://query1.data.site.com/v7/finance/download/MYTEXT?period1=1664641287&period2=1696177287&interval=1d&events=history&includeAdjustedClose=true I need to take only MYTEXT These values changes MYTEXT 1664641287 1696177287 1d I tried with string.replace but I don't know how to…

VIEW QUESTION
Back To Top
Search