How to show below javaScript code without brackets? [duplicate] - javascript

This question already has answers here:
Easy way to turn JavaScript array into comma-separated list?
(22 answers)
Closed 2 years ago.
Code:
let myClassFellows=[ ['Noor',1],['Jawaria',2]];
console.log(myClassFellows[0]);
Below is the output I want to show without the square brackets

What do you mean without square brackets? Like 'Noor', 1?
If so, you need to concatenate it into a string with myClassFellows[0].join(', ').

Related

How get words into a JS Array? [duplicate]

This question already has answers here:
How can I convert a comma-separated string to an array?
(19 answers)
Closed 2 years ago.
I have a problem, but I don't know how to solve it.
I got a handful of words from Cookies.get, separated by commas. Like this: apple,pineapple,tomato How can I put these words into an array?
Thank you very much.
Use the split method. Ex. words.split(","). Documentation here.

RegExp with variable in a string format [duplicate]

This question already has answers here:
Why do regex constructors need to be double escaped?
(5 answers)
Javascript Regex: How to put a variable inside a regular expression? [duplicate]
(9 answers)
Closed 2 years ago.
I created a RegExp that works as expected however I can't get it to work in a string format
var regex = new RegExp(/IN1\|2.*\r/g);
The regex is supposed to match the line number which will be taken from variable, in above example it would be line number 2. My question is how do I get it to a string format with a variable inside it?
I tried following but it just doesn't work: "IN1\|" + lineNumber + ".*\x0d//g"
Below is a text in case anyone wants to try:
IN1|**1**||QQ|Noth||||||||20190413|20190413||Self\r
IN1|**2**||QQ|Noth||||||||20190413|20190413||Self\r
IN1|**3**||QQ|LHS||||||||20200506|""||Private|||||||||||||||||||||2342344\r
Thank you.

ValidationExpression for a number that doesn't consisting of just zeros [duplicate]

This question already has answers here:
Need a regular expression - disallow all zeros
(7 answers)
Closed 5 years ago.
I have asp:RegularExpressionValidator and the ValidationExpression is "\d{0,9}"
My problem is that I can't get a number consisting of just zeros.
How can I check this kind of thing?
Thanks for the help
Maybe this is what you're looking for:
/^[0]{0,9}$/

Accessing json keys with special characters in javascript [duplicate]

This question already has answers here:
How can I access object properties containing special characters?
(2 answers)
Closed 8 years ago.
I have an object which looks like this:
{"response":{"mydata":[{"xxx:id":"8c8b9703-bc87-40d8-b8d7-f71ebff4002a","Description":"Tsameple desc"].....
Now, my question is, How do I access the Id field?
I have tried
$.response.mydata[i].xxx:id
However, this is resulting in an error thanks to the ":" in the key value. Any tips on how I can get the value?
Use the bracket notation :
response.mydata[i]['xxx:id']

Specific Regular Expression In Javascript with a condition [duplicate]

This question already has answers here:
How can I get query string values in JavaScript?
(73 answers)
Parsing an URL in JavaScript
(3 answers)
Closed 8 years ago.
How to format a regular expression In JavaScript :
http://localhost:3000/sales?&tp=Home+Stay&am=Pool&pl=1620&pt=Flash+Sale&st=5
I want to get &pl= and all the digits after &pl=.
So the result would be &pl=1620 in this case.
Please help how to perform this??
Your help means a lot for me.
This script will do the trick:
var regex = /&pl=\d*/;
var match = regex.exec(yourtext)[0];
Following regex should do it
/&pl=\d*/.exec('http://localhost:3000/sales?&tp=Home+Stay&am=Pool&pl=1620&pt=Flash+Sale&st=5')[0]
Demo: Fiddel

Categories