in Education by
What's the best way to extract the key and value from a string like this: var myString = 'A1234=B1234'; I originally had something like this: myString.split('='); And that works fine, BUT an equal (=) sign could be used as a key or value within the string plus the string could have quotes, like this: var myString = '"A123=1=2=3=4"="B1234"'; The string could also only have one pair of quotes and spaces: var myString = ' "A123=1=2=3=4" = B1234 '; I'm not very good at regular expressions but I'm guessing that's the way forward? What I want to end up with is two variables, key and value, in the case above, the key variable would end up being A123=1=2=3=4 and the value variable would be B1234. If there is no value present, for example if this were the original string: var myString = 'A1234'; Then I would want the key variable to be 'A1234' and for the value variable to be null or false - or something I can test against. Any help is appreciated. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

Related questions

0 votes
    I'm new to JavaScript. I have the following object: let obj1 = [{ 'id': 1, 'longString': ' ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I'm new to JavaScript. I have the following object: let obj1 = [{ 'id': 1, 'longString': ' ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to split a string with angularJS (4 answers) Closed 5 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to split a string with angularJS (4 answers) Closed 5 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to split a string with angularJS (4 answers) Closed 5 years ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    Is there a better way than this to splice an array into another array in javascript var string = ' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    I am trying to convert string into integer using jquery but it throwing NumberFormatException. How to fix it ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    what is the easiest way to convert a Blob into a byte array?I am using MYSQL and i want to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    what is the easiest way to convert a Blob into a byte array?I am using MYSQL and i want to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    Have jquery dialog as closeOnescape as false. want to trigger an event based on esc key press how do ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I am looking for a way to close a component when there it a click outisde of the element. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    var str = ' Header Paragraph I have a string str I want to separate h1 and p text. Result: var ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    var str = ' Header Paragraph I have a string str I want to separate h1 and p text. Result: var ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
...