I am trying to send a JSON string and parse it in my server side in node js.
I want to extract specific values like title but for some reason I get undefined when I try to parse it.
This is what I tried so far.
Home.ejs
$.each(item, function(key, value)
{
var s = JSON.stringify(value);
s = s.replace(/^\s+|\s+$/g,'');
info.push(s);
});
console.log("info",info);
if (response.status == 'ok') {
$.ajax({
type: 'POST',
url: '/home',
data: JSON.stringify(info),
success: function (data) {
},
error: function (data) {
console.log('error');
console.log(data)
}
});
}
This is what it prints out in the console.
info
(20) ["{"title":"Trump ends self-made crisis","pubDate":"…tweet-restricted-super-169.jpg"},"categories":[]}", "{"title":"Intel chiefs: Trump suggested we refute …-mueller-split-4-super-169.jpg"},"categories":[]}", "{"title":"New details emerge in US destroyer colli…ald-damaged-0617-super-169.jpg"},"categories":[]}", "{"title":"Former US government worker charged with…dana-boente-0510-super-169.jpg"},"categories":[]}", "{"title":"Sniper hits ISIS target from over 2 mile…110754-isis-flag-super-169.png"},"categories":[]}", "{"title":"Grenfell Tower blaze: Other London high-…london-fire-0614-super-169.jpg"},"categories":[]}", "{"title":"Prime Minister May offer: EU citizens ca…2344-theresa-may-super-169.jpg"},"categories":[]}", "{"title":"Ousted South Korean president's confidan…outh-korea-court-super-169.jpg"},"categories":[]}", "{"title":"Why neither North Korea nor the United S…k-in-photos-0421-super-169.jpg"},"categories":[]}", "{"title":"Warmbier funeral: 2,500 celebrate kid wh…ier-funeral-0622-super-169.jpg"},"categories":[]}", "{"title":"US, Japan missile interception test fail…issile-launch-02-super-169.jpg"},"categories":[]}", "{"title":"US officials: North Korea tested rocket …ek-in-photo-0519-super-169.jpg"},"categories":[]}", "{"title":"Zuckerberg: Why Facebook's mission chang…-interview-color-super-169.jpg"},"categories":[]}", "{"title":"Fitness model dies after freak kitchen a…burger-instagram-super-169.jpg"},"categories":[]}", "{"title":"Tropical Storm Cindy brings rain, wind t…ig-tbkl-00001316-super-169.jpg"},"categories":[]}", "{"title":"Taliban claim car bomb that killed 30","…an-car-bomb-0622-super-169.jpg"},"categories":[]}", "{"title":"The images Saudi Arabia doesn't want you…war-malnutrition-super-169.jpg"},"categories":[]}", "{"title":"Fact Check: Has Trump created 33,000 min…ig-alee-00003930-super-169.jpg"},"categories":[]}", "{"title":"What do young Indians think of Donald Tr…trump-modi-split-super-169.jpg"},"categories":[]}", "{"title":"Obama blasts Republican health care bill…5-obama-montreal-super-169.jpg"},"categories":[]}"]
0
:
"{"title":"Trump ends self-made crisis","pubDate":"2017-06-22 22:36:00","link":"http://www.cnn.com/2017/06/22/politics/trump-comey-tapes-recordings-white-house/index.html","guid":"http://www.cnn.com/2017/06/22/politics/trump-comey-tapes-recordings-white-house/index.html","author":"","thumbnail":"","description":"President Donald Trump finally, grudgingly, had no choice but to come clean.","content":"President Donald Trump finally, grudgingly, had no choice but to come clean.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622175804-trump-tweet-restricted-super-169.jpg"},"categories":[]}"
1
:
"{"title":"Intel chiefs: Trump suggested we refute Russia collusion","pubDate":"2017-06-22 10:47:14","link":"http://www.cnn.com/collections/intel-intl/","guid":"http://www.cnn.com/collections/intel-intl/","author":"","thumbnail":"","description":"","content":"","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622120332-trump-mueller-split-4-super-169.jpg"},"categories":[]}"
2
:
"{"title":"New details emerge in US destroyer collision investigation","pubDate":"2017-06-22 23:31:38","link":"http://www.cnn.com/2017/06/22/politics/uss-fitzgerald-investigation-update/index.html","guid":"http://www.cnn.com/2017/06/22/politics/uss-fitzgerald-investigation-update/index.html","author":"","thumbnail":"","description":"Five of the seven Navy sailors who died aboard the USS Fitzgerald when it collided with a cargo ship off the east coast of Japan may have been almost instantly \"incapacitated\" and died quickly, according to a very preliminary Navy analysis, a defense official told CNN.","content":"Five of the seven Navy sailors who died aboard the USS Fitzgerald when it collided with a cargo ship off the east coast of Japan may have been almost instantly \"incapacitated\" and died quickly, according to a very preliminary Navy analysis, a defense official told CNN.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170617081911-07-uss-fitzgerald-damaged-0617-super-169.jpg"},"categories":[]}"
3
:
"{"title":"Former US government worker charged with giving top-secret info to China","pubDate":"2017-06-22 23:13:14","link":"http://www.cnn.com/2017/06/22/politics/top-secret-information-china/index.html","guid":"http://www.cnn.com/2017/06/22/politics/top-secret-information-china/index.html","author":"","thumbnail":"","description":"The Justice Department announced Thursday that it had arrested and charged a former US government employee for sharing top-secret information with a Chinese government agent.","content":"The Justice Department announced Thursday that it had arrested and charged a former US government employee for sharing top-secret information with a Chinese government agent.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170510133509-dana-boente-0510-super-169.jpg"},"categories":[]}"
4
:
"{"title":"Sniper hits ISIS target from over 2 miles away","pubDate":"2017-06-23 00:54:32","link":"http://www.cnn.com/2017/06/22/politics/canadian-sniper-record-shot-isis/index.html","guid":"http://www.cnn.com/2017/06/22/politics/canadian-sniper-record-shot-isis/index.html","author":"","thumbnail":"","description":"A Canadian special operations sniper successfully hit an ISIS fighter from a record-breaking distance of more than two miles away while assisting Iraqi forces in the push to retake Mosul, according to Canadian Special Operations Command.","content":"A Canadian special operations sniper successfully hit an ISIS fighter from a record-breaking distance of more than two miles away while assisting Iraqi forces in the push to retake Mosul, according to Canadian Special Operations Command.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/160618110754-isis-flag-super-169.png"},"categories":[]}"
5
:
"{"title":"Grenfell Tower blaze: Other London high-rises 'combustible'","pubDate":"2017-06-23 02:40:44","link":"http://www.cnn.com/2017/06/22/europe/grenfell-tower-fire-theresa-may/index.html","guid":"http://www.cnn.com/2017/06/22/europe/grenfell-tower-fire-theresa-may/index.html","author":"","thumbnail":"","description":"Initial tests on cladding in a number of tower blocks in London have come back as combustible, British Prime Minister Theresa May told the House of Commons Thursday during a statement about last week's fatal Grenfell Tower blaze.","content":"Initial tests on cladding in a number of tower blocks in London have come back as combustible, British Prime Minister Theresa May told the House of Commons Thursday during a statement about last week's fatal Grenfell Tower blaze.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170614142852-45-london-fire-0614-super-169.jpg"},"categories":[]}"
6
:
"{"title":"Prime Minister May offer: EU citizens can stay in UK","pubDate":"2017-06-23 02:06:22","link":"http://www.cnn.com/2017/06/22/europe/theresa-may-brexit-rights/index.html","guid":"http://www.cnn.com/2017/06/22/europe/theresa-may-brexit-rights/index.html","author":"","thumbnail":"","description":"In a Brexit divorce deal offering, British Prime Minister Theresa May on Thursday said European Union citizens would be allowed to stay in the United Kingdom after the country leaves the EU.","content":"In a Brexit divorce deal offering, British Prime Minister Theresa May on Thursday said European Union citizens would be allowed to stay in the United Kingdom after the country leaves the EU.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170620152344-theresa-may-super-169.jpg"},"categories":[]}"
7
:
"{"title":"Ousted South Korean president's confidante sentenced to 3 years","pubDate":"2017-06-23 05:53:19","link":"http://www.cnn.com/2017/06/22/asia/south-korea-choi-soon-sil/index.html","guid":"http://www.cnn.com/2017/06/22/asia/south-korea-choi-soon-sil/index.html","author":"","thumbnail":"","description":"The confidante of former South Korean President Park Geun-hye has been sentenced to three years in prison for soliciting favors for her daughter, a press officer from the Seoul Central District Court told CNN Friday.","content":"The confidante of former South Korean President Park Geun-hye has been sentenced to three years in prison for soliciting favors for her daughter, a press officer from the Seoul Central District Court told CNN Friday.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/161219150546-01-choi-soon-sil-south-korea-court-super-169.jpg"},"categories":[]}"
8
:
"{"title":"Why neither North Korea nor the United States want all-out war","pubDate":"2017-06-23 05:50:20","link":"http://www.cnn.com/2017/06/22/asia/north-korea-war-devastation/index.html","guid":"http://www.cnn.com/2017/06/22/asia/north-korea-war-devastation/index.html","author":"","thumbnail":"","description":"It's been a tense six months on the Korean Peninsula and many North Korea watchers believe the situation is dangerous.","content":"It's been a tense six months on the Korean Peninsula and many North Korea watchers believe the situation is dangerous.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170420182131-05-week-in-photos-0421-super-169.jpg"},"categories":[]}"
9
:
"{"title":"Warmbier funeral: 2,500 celebrate kid who would've 'set the world on fire'","pubDate":"2017-06-22 16:55:31","link":"http://www.cnn.com/collections/intl-warmbier-funeral/","guid":"http://www.cnn.com/collections/intl-warmbier-funeral/","author":"","thumbnail":"","description":"","content":"","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622152959-08-otto-warmbier-funeral-0622-super-169.jpg"},"categories":[]}"
10
:
"{"title":"US, Japan missile interception test fails","pubDate":"2017-06-23 03:05:10","link":"http://www.cnn.com/2017/06/22/politics/us-missile-intercept-test-fails/index.html","guid":"http://www.cnn.com/2017/06/22/politics/us-missile-intercept-test-fails/index.html","author":"","thumbnail":"","description":"A US and Japanese missile test conducted in Hawaii missed its target, but both militaries stopped short of calling it a failure.","content":"A US and Japanese missile test conducted in Hawaii missed its target, but both militaries stopped short of calling it a failure.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170206111347-standard-missile-launch-02-super-169.jpg"},"categories":[]}"
11
:
"{"title":"US officials: North Korea tested rocket engine","pubDate":"2017-06-22 23:31:27","link":"http://www.cnn.com/videos/world/2017/06/22/north-korea-tests-rocket-todd-dnt-tsr.cnn","guid":"http://www.cnn.com/videos/world/2017/06/22/north-korea-tests-rocket-todd-dnt-tsr.cnn","author":"","thumbnail":"","description":"Tensions between the US and North Korea continue to rise after North Korea tested a rocket engine, according to US officials. CNN's Brian Todd reports.","content":"Tensions between the US and North Korea continue to rise after North Korea tested a rocket engine, according to US officials. CNN's Brian Todd reports.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170518180155-09-week-in-photo-0519-super-169.jpg"},"categories":[]}"
12
:
"{"title":"Zuckerberg: Why Facebook's mission changed","pubDate":"2017-06-22 20:06:19","link":"http://money.cnn.com/2017/06/22/technology/facebook-zuckerberg-interview/index.html","guid":"http://money.cnn.com/2017/06/22/technology/facebook-zuckerberg-interview/index.html","author":"","thumbnail":"","description":"","content":"","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622131016-02-zuckerberg-interview-color-super-169.jpg"},"categories":[]}"
13
:
"{"title":"Fitness model dies after freak kitchen accident, family says","pubDate":"2017-06-22 19:15:18","link":"http://www.cnn.com/2017/06/22/world/rebecca-burger-whipped-cream-instagram-fitness-model-death-trnd/index.html","guid":"http://www.cnn.com/2017/06/22/world/rebecca-burger-whipped-cream-instagram-fitness-model-death-trnd/index.html","author":"","thumbnail":"","description":"A popular social media fitness personality died after what can only be described as a freak accident involving a whipped cream canister.","content":"A popular social media fitness personality died after what can only be described as a freak accident involving a whipped cream canister.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622112522-0622-rebecca-burger-instagram-super-169.jpg"},"categories":[]}"
14
:
"{"title":"Tropical Storm Cindy brings rain, wind to Gulf Coast","pubDate":"2017-06-22 22:24:14","link":"http://www.cnn.com/videos/us/2017/06/22/tropical-storm-cindy-orig-tbkl.cnn","guid":"http://www.cnn.com/videos/us/2017/06/22/tropical-storm-cindy-orig-tbkl.cnn","author":"","thumbnail":"","description":"Six million people are under tornado watch in Louisiana, Mississippi and Alabama.","content":"Six million people are under tornado watch in Louisiana, Mississippi and Alabama.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622181943-tropical-storm-cindy-orig-tbkl-00001316-super-169.jpg"},"categories":[]}"
15
:
"{"title":"Taliban claim car bomb that killed 30","pubDate":"2017-06-22 14:28:56","link":"http://www.cnn.com/2017/06/22/asia/afghanistan-car-bomb/index.html","guid":"http://www.cnn.com/2017/06/22/asia/afghanistan-car-bomb/index.html","author":"","thumbnail":"","description":"At least 30 people were killed Thursday in a car bomb attack outside a bank in Lashkar Gah, the capital of Afghanistan's southern Helmand province, officials said.","content":"At least 30 people were killed Thursday in a car bomb attack outside a bank in Lashkar Gah, the capital of Afghanistan's southern Helmand province, officials said.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622071724-01-afghanistan-car-bomb-0622-super-169.jpg"},"categories":[]}"
16
:
"{"title":"The images Saudi Arabia doesn't want you to see","pubDate":"2017-06-22 16:26:56","link":"http://www.cnn.com/2017/06/21/middleeast/yemen-malnutrition-cholera-crisis-images/index.html","guid":"http://www.cnn.com/2017/06/21/middleeast/yemen-malnutrition-cholera-crisis-images/index.html","author":"","thumbnail":"","description":"Batool Ali is six years old, though you would never guess that from her huge, haunted eyes and emaciated frame. Ribs jutting out over her distended belly, Batool weighs less than 16 kilograms (35 pounds). She is one of nearly half a million children in Yemen suffering from severe malnutrition.","content":"Batool Ali is six years old, though you would never guess that from her huge, haunted eyes and emaciated frame. Ribs jutting out over her distended belly, Batool weighs less than 16 kilograms (35 pounds). She is one of nearly half a million children in Yemen suffering from severe malnutrition.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170619144015-12-yemen-civil-war-malnutrition-super-169.jpg"},"categories":[]}"
17
:
"{"title":"Fact Check: Has Trump created 33,000 mining jobs?","pubDate":"2017-06-22 23:59:36","link":"http://www.cnn.com/videos/politics/2017/06/22/fact-check-trump-mining-orig-alee.cnn","guid":"http://www.cnn.com/videos/politics/2017/06/22/fact-check-trump-mining-orig-alee.cnn","author":"","thumbnail":"","description":"CNN's Jake Tapper, in partnership with FactCheck.org, checks a Trump claim that the President added 33,000 mining jobs since his inauguration.","content":"CNN's Jake Tapper, in partnership with FactCheck.org, checks a Trump claim that the President added 33,000 mining jobs since his inauguration.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170622195811-fact-check-trump-mining-orig-alee-00003930-super-169.jpg"},"categories":[]}"
18
:
"{"title":"What do young Indians think of Donald Trump?","pubDate":"2017-06-23 05:02:14","link":"http://www.cnn.com/2017/06/22/asia/young-indians-trump/index.html","guid":"http://www.cnn.com/2017/06/22/asia/young-indians-trump/index.html","author":"","thumbnail":"","description":"Indian Prime Minister Narendra Modi is set to meet US President Donald Trump for the first time on Monday.","content":"Indian Prime Minister Narendra Modi is set to meet US President Donald Trump for the first time on Monday.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170125123753-trump-modi-split-super-169.jpg"},"categories":[]}"
19
:
"{"title":"Obama blasts Republican health care bill","pubDate":"2017-06-23 02:11:50","link":"http://www.cnn.com/2017/06/22/politics/barack-obama-health-care-bill-reaction/index.html","guid":"http://www.cnn.com/2017/06/22/politics/barack-obama-health-care-bill-reaction/index.html","author":"","thumbnail":"","description":"President Barack Obama on Thursday spoke out against a proposed GOP Senate bill that dismantles the Affordable Care Act, also known as Obamacare.","content":"President Barack Obama on Thursday spoke out against a proposed GOP Senate bill that dismantles the Affordable Care Act, also known as Obamacare.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170606215725-obama-montreal-super-169.jpg"},"categories":[]}"
server.js
app.post("/home",function(req,res)
{
var data = (req.body);
console.log("name",data);
var news_title = [];
var news_link =[];
var news_date =[];
/*for(var i in req.body){
var item = req.body.items[i];
//console.log(item);
}*/
//console.log("name",name);
});
This is what it prints out in the console
name { '["{\"title\":\"Trump ends self-made crisis\",\"pubDate\":\"2017-06-22 22:36:00\",\"link\":\"http://www.cnn.com/2017/06/22/politics/trump-comey-tapes-recordings-white-house/index.html\",\"guid\":\"http://www.cnn.com/2017/06/22/politics/trump-comey-tapes-recordings-white-house/index.html\",\"author\":\"\",\"thumbnail\":\"\",\"description\":\"President Donald Trump finally, grudgingly, had no choice but to come clean.\",\"content\":\"President Donald Trump finally, grudgingly, had no choice but to come clean.\",\"enclosure\":{\"link\":\"http://i2.cdn.turner.com/cnnnext/dam/assets/170622175804-trump-tweet-restricted-super-169.jpg\"},\"categories\":': [ '' ] }
name { '["{\"title\":\"Trump ends self-made crisis\",\"pubDate\":\"2017-06-22 22:36:00\",\"link\":\"http://www.cnn.com/2017/06/22/politics/trump-comey-tapes-recordings-white-house/index.html\",\"guid\":\"http://www.cnn.com/2017/06/22/politics/trump-comey-tapes-recordings-white-house/index.html\",\"author\":\"\",\"thumbnail\":\"\",\"description\":\"President Donald Trump finally, grudgingly, had no choice but to come clean.\",\"content\":\"President Donald Trump finally, grudgingly, had no choice but to come clean.\",\"enclosure\":{\"link\":\"http://i2.cdn.turner.com/cnnnext/dam/assets/170622175804-trump-tweet-restricted-super-169.jpg\"},\"categories\":': [ '' ] }
I want to extract the title value but for some reason I keep getting undefined when I try req.body.title.
It looks like you are having an issue because you are using JSON.stringify on each array element and then using JSON.stringify on the compiled array.
You should get the expected outcome by stringifying the whole array without stringifying each part. i.e. in your case just stringify the item
$.ajax({
type: 'POST',
url: '/home',
data: JSON.stringify(item),
success: function (data) {
}
Related
I am being passed a JSON.stringified Array of arrays in a var called request.
alert(request);
gives this message:
"[[\"0\",\"MahaShivRatri\"],[\"0\",\"A Night with the Divine\"],[\"0\",\"Attend In-Person\"],[\"0\",\"11 March 2021\"],[\"0\",\"6 PM to 6 AM IST\"],[\"0\",\"Attend Mahashivratri celebrations with Sadhguru in the presence of Adiyogi at the Isha Yoga Center\"],............
now, I try this:
var arr = JSON.parse(request);
alert(arr);
It gives the below message which looks like an Array of arrays:
[["0","MahaShivRatri"],["0","A Night with the Divine"],["0","Attend In-Person"],["0","11 March 2021"],["0","6 PM to 6 AM IST"],["0","Attend Mahashivratri celebrations with Sadhguru in the presence of Adiyogi at the Isha Yoga Center"],.........
but when I try to alert a particular element of this Array:
alert(arr[0][1]);
It gives undefined in the alert box.
How to get an Array of arrays from a JSON.stringified Array of arrays?
(Essentially I want to manipulate the DOM while I loop through arr.)
Thank you.
Edits
1. The original full stringified request is this :
console.log(request);
logs this
"[[\"0\",\"MahaShivRatri\"],[\"0\",\"A Night with the Divine\"],[\"0\",\"Attend In-Person\"],[\"0\",\"11 March 2021\"],[\"0\",\"6 PM to 6 AM IST\"],[\"0\",\"Attend Mahashivratri celebrations with Sadhguru in the presence of Adiyogi at the Isha Yoga Center\"],[\"0\",\"Limited Seats Available\"],[\"0\",\"<CTA> - BOOK YOUR SEAT NOW \"],[\"0\",\"In-person attendance is open only for people in India due to COVID protocols.\"],[\"1\",\"SECTION HEADING- 2021 Celebrations Highlights\"],[\"1\",\"Mahashivratri is an exuberant nightlong festival with explosive meditations by Sadhguru and spectacular musical performances by renowned artists. Join the celebrations and experience the grace of Adiyogi.\"],[\"1\",\"\"],[\"1\",\" <text limit - 110 chars> Powerful Satsang with Sadhguru Explosive guided meditations with Sadhguru Nightlong special musical performances by eminent artists Adiyogi Divya Darshanam, a spectacular light & sound show depicting the origin of Yoga Devi Maha Arati, a grand procession of the Linga Bhairavi Utsava Murti Cultural performances by Sounds Of Isha Traditional and Martial Arts performances by Isha Samskriti students\"],[\"1\",\" \"],[\"1\",\" \"],[\"2\",\"SEATING LAYOUT\"],[\"2\",\"- Seating is open only for people in India. - Booking is open on a first-come-first-serve basis - COVID precautions are mandatory (See FAQ)\"],[\"2\",\"HOW TO REACH THE VENUE\"],[\"2\",\"Isha Yoga Center,\"],[\"2\",\"Velliangiri Foothills,\"],[\"2\",\"Ishana Vihar Post,\"],[\"2\",\"Coimbatore 641 114, India\"],[\"2\",\"Contact\"],[\"2\",\"83000 82000\"],[\"2\",\"info#mahashivarathri.org\"],[\"3\",\"Additional Information\"],[\"3\",\"Your contribution towards the event will help us make the possibilities of this night available to millions around the world.\"],[\"3\",\"Limited Seats Available\"],[\"3\",\"<CTA> - BOOK YOUR SEAT NOW \"],[\"3\",\"\"],[\"3\",\"\"],[\"3\",\"Invite Your Family and Friends\"],[\"4\",\"\"],[\"4\",\" Frequently Asked Questions\"],[\"4\",\"In-Person Attendance FAQ\"],[\"4\",\"What precautions should attendees take in light of COVID-19?\"],[\"4\",\"Since the guidelines are regularly evolving, the currently applicable guidelines issued by the government and local health authorities will be followed. Participants must abide by these guidelines:\"],[\"4\",\"• It is mandatory to wear a mask at all times.\"],[\"4\",\"• You must adhere to all social distancing protocols and COVID-19 safety guidelines laid down during the event.\"],[\"4\",\"• Get a COVID test done within a 96-hour period before your arrival at the Isha Yoga Center.\"],[\"4\",\"• We recommend that you practice Simha Kriya regularly and consume Nilavembu Kashayam daily, leading up to the event.\"],[\"4\",\"Can I register offline?\"],[\"4\",\"Yes. For more information, call 83000 82000.\"],[\"4\",\"What documents will I need when I arrive at the Isha Yoga Center?\"],[\"4\",\"Please bring:\"],[\"4\",\"The same valid government-issued photo identification that you used to register for MahashivratriPrintout of the E-pass that was sent to you via email\"],[\"4\",\"What time do I need to reach the Isha Yoga Center for the event?\"],[\"4\",\"Check-in counters will be open only from 10 AM to 3 PM on the day of the event for those who have pre-registered. We request you to plan your travel accordingly since we will not be able to accommodate check-ins outside these timings.\"],[\"4\",\"Please stay back for the event until 6 AM on 12 March. Due to security reasons, participants will not be allowed to leave the venue once checked-in.\"],[\"4\",\"Restroom facilities are available at the venue.\"],[\"4\",\"I don’t know Tamil. Can I still attend this program?\"],[\"4\",\"Yes, Mahashivratri will be conducted in English with Tamil translation. Live translation for online participants will be available in 7 Indian languages (Tamil, Hindi, Marathi, Bangla, Telugu, Kannada, and Malayalam) and 5 global languages (Russian, Mandarin, Spanish, French, and Portuguese).\"],[\"4\",\"I have difficulty sitting on the floor.\"],[\"4\",\"Chairs will be provided for the entire duration of the event.\"],[\"4\",\"Will accommodation be provided during the program?\"],[\"4\",\"No. Accommodation will not be provided for Mahashivratri participants.\"],[\"4\",\"Can I bring family members/guests with me?\"],[\"4\",\"No, entry is limited to registered participants only.\"],[\"4\",\"Can I bring my children? What is the minimum age required to participate in the program?\"],[\"4\",\"We do not have facilities or resources to take care of children and/or minors during the event. We request you to arrange guardianship at home for them while you are here. Alternatively, you could choose to stay in Coimbatore and come to Mahashivratri with your family. In such a case, please register for seating passes for your family as well.\"],[\"4\",\"The minimum age for participants is 10 years. \"],[\"4\",\"What kind of food can I bring to the event?\"],[\"4\",\"Maha Annadanam – an offering of food – will be provided to everyone attending the event. If you have to carry your own food due to dietary restrictions, you can carry wholesome vegetarian meals.\"],[\"4\",\"Can I bring my vehicle? Is parking available?\"],[\"4\",\"Limited parking will be available. Parking is at the owner’s risk and no liability will be taken by event organizers.\"],[\"4\",\"Can I register for Mahashivratri on arrival at the venue?\"],[\"4\",\"No. Spot registrations will not be available. We recommend that you register for Mahashivratri at least 15 days before the event. \"],[\"4\",\"How do I know if my registration is complete?\"],[\"4\",\"Once you register for Mahashivratri, you will receive an E-receipt and a confirmation email with your registration number. Closer to the event, an E-pass will be sent to you via email.\"],[\"4\",\"I have not attended Inner Engineering. Can I take part in Mahashivratri?\"],[\"4\",\"Yes, the Isha Mahashivratri event is open to everyone.\"],[\"5\",\"\"],[\"6\",\"NA\"]]"
2. When I parse it and then log it:
var arr = JSON.parse(request);
console.log(arr);
This gets logged:
[["0","MahaShivRatri"],["0","A Night with the Divine"],["0","Attend In-Person"],["0","11 March 2021"],["0","6 PM to 6 AM IST"],["0","Attend Mahashivratri celebrations with Sadhguru in the presence of Adiyogi at the Isha Yoga Center"],["0","Limited Seats Available"],["0","<CTA> - BOOK YOUR SEAT NOW "],["0","In-person attendance is open only for people in India due to COVID protocols."],["1","SECTION HEADING- 2021 Celebrations Highlights"],["1","Mahashivratri is an exuberant nightlong festival with explosive meditations by Sadhguru and spectacular musical performances by renowned artists. Join the celebrations and experience the grace of Adiyogi."],["1",""],["1"," <text limit - 110 chars> Powerful Satsang with Sadhguru Explosive guided meditations with Sadhguru Nightlong special musical performances by eminent artists Adiyogi Divya Darshanam, a spectacular light & sound show depicting the origin of Yoga Devi Maha Arati, a grand procession of the Linga Bhairavi Utsava Murti Cultural performances by Sounds Of Isha Traditional and Martial Arts performances by Isha Samskriti students"],["1"," "],["1"," "],["2","SEATING LAYOUT"],["2","- Seating is open only for people in India. - Booking is open on a first-come-first-serve basis - COVID precautions are mandatory (See FAQ)"],["2","HOW TO REACH THE VENUE"],["2","Isha Yoga Center,"],["2","Velliangiri Foothills,"],["2","Ishana Vihar Post,"],["2","Coimbatore 641 114, India"],["2","Contact"],["2","83000 82000"],["2","info#mahashivarathri.org"],["3","Additional Information"],["3","Your contribution towards the event will help us make the possibilities of this night available to millions around the world."],["3","Limited Seats Available"],["3","<CTA> - BOOK YOUR SEAT NOW "],["3",""],["3",""],["3","Invite Your Family and Friends"],["4",""],["4"," Frequently Asked Questions"],["4","In-Person Attendance FAQ"],["4","What precautions should attendees take in light of COVID-19?"],["4","Since the guidelines are regularly evolving, the currently applicable guidelines issued by the government and local health authorities will be followed. Participants must abide by these guidelines:"],["4","• It is mandatory to wear a mask at all times."],["4","• You must adhere to all social distancing protocols and COVID-19 safety guidelines laid down during the event."],["4","• Get a COVID test done within a 96-hour period before your arrival at the Isha Yoga Center."],["4","• We recommend that you practice Simha Kriya regularly and consume Nilavembu Kashayam daily, leading up to the event."],["4","Can I register offline?"],["4","Yes. For more information, call 83000 82000."],["4","What documents will I need when I arrive at the Isha Yoga Center?"],["4","Please bring:"],["4","The same valid government-issued photo identification that you used to register for MahashivratriPrintout of the E-pass that was sent to you via email"],["4","What time do I need to reach the Isha Yoga Center for the event?"],["4","Check-in counters will be open only from 10 AM to 3 PM on the day of the event for those who have pre-registered. We request you to plan your travel accordingly since we will not be able to accommodate check-ins outside these timings."],["4","Please stay back for the event until 6 AM on 12 March. Due to security reasons, participants will not be allowed to leave the venue once checked-in."],["4","Restroom facilities are available at the venue."],["4","I don’t know Tamil. Can I still attend this program?"],["4","Yes, Mahashivratri will be conducted in English with Tamil translation. Live translation for online participants will be available in 7 Indian languages (Tamil, Hindi, Marathi, Bangla, Telugu, Kannada, and Malayalam) and 5 global languages (Russian, Mandarin, Spanish, French, and Portuguese)."],["4","I have difficulty sitting on the floor."],["4","Chairs will be provided for the entire duration of the event."],["4","Will accommodation be provided during the program?"],["4","No. Accommodation will not be provided for Mahashivratri participants."],["4","Can I bring family members/guests with me?"],["4","No, entry is limited to registered participants only."],["4","Can I bring my children? What is the minimum age required to participate in the program?"],["4","We do not have facilities or resources to take care of children and/or minors during the event. We request you to arrange guardianship at home for them while you are here. Alternatively, you could choose to stay in Coimbatore and come to Mahashivratri with your family. In such a case, please register for seating passes for your family as well."],["4","The minimum age for participants is 10 years. "],["4","What kind of food can I bring to the event?"],["4","Maha Annadanam – an offering of food – will be provided to everyone attending the event. If you have to carry your own food due to dietary restrictions, you can carry wholesome vegetarian meals."],["4","Can I bring my vehicle? Is parking available?"],["4","Limited parking will be available. Parking is at the owner’s risk and no liability will be taken by event organizers."],["4","Can I register for Mahashivratri on arrival at the venue?"],["4","No. Spot registrations will not be available. We recommend that you register for Mahashivratri at least 15 days before the event. "],["4","How do I know if my registration is complete?"],["4","Once you register for Mahashivratri, you will receive an E-receipt and a confirmation email with your registration number. Closer to the event, an E-pass will be sent to you via email."],["4","I have not attended Inner Engineering. Can I take part in Mahashivratri?"],["4","Yes, the Isha Mahashivratri event is open to everyone."],["5",""],["6","NA"]]
3. finally
console.log(arr[0]);
logs just this:
[
Assuming the ............ at the end of the string in result is not really part of the string (and is just there to indicate there's more data you haven't posted) then the code you've posted already works correctly (as demonstrated below):
const request = "[[\"0\",\"MahaShivRatri\"],[\"0\",\"A Night with the Divine\"],[\"0\",\"Attend In-Person\"],[\"0\",\"11 March 2021\"],[\"0\",\"6 PM to 6 AM IST\"],[\"0\",\"Attend Mahashivratri celebrations with Sadhguru in the presence of Adiyogi at the Isha Yoga Center\"]]";
const arr = JSON.parse(request);
console.log(arr[0][1]);
My code won't work infinite scrolling please help. My progress bar is working just fine but my infinite scroll isn't working at all. I want to repeat the same content over and over again with an infinite scroll.
<body>
<div class="header">
<div class="container">
<div class="progress-bar" id="mybar"></div>
</div>
</div>
<section>
<nav>
<a id="Home">Home</a>
<a id="News">News</a>
<a id="Sports">Sports</a>
<a id="Media">Media</a>
</nav>
</section>
<main id="content">
<article>
<section1 class="full-viewport">
<blockquote>Toronto's Latest News</blockquote>
<p>On March 23, Mayor John Tory declared an Emergency Opens in new window in the city of Toronto. The declaration of a municipal emergency PDF is part of the City’s ongoing efforts to stop the spread of COVID-19 and will ensure the municipal government can continue to act and respond quickly to the pandemic and any other events that arise in the weeks ahead.
Listen to a message from Mayor John Tory Opens in new window and hear more about the importance of staying home Opens in new window and what you can do to help.
Toronto Public Health has had 591 cases of COVID-19 reported in Toronto. Currently, 67 of these people are hospitalized and there are 30 in ICU. Among cases of COVID-19 in Toronto, there have been 6 deaths to-date. There have been 30 other people diagnosed with COVID-19 who have recovered from their illness. This data was extracted from the Integrated Public Health Information System at 1 p.m. on March 30, 2020. The numbers may differ from other sources, as data are extracted at different times.
If you think you have COVID-19 symptoms or have been in close contact with someone who has it, find out if you should visit an assessment centre and where the nearest location is.</p>
<p>As part of the daily ministerial update on the federal plan to combat the novel coronavirus, Defence Minister Harjit Sajjan and Chief of Defence Staff Jonathan Vance offered more details about how the Canadian Armed Forces are planning to handle any calls to assist pandemic response efforts.
Sajjan said that, in anticipation of a surge in cases, the military took precautionary measures to make sure their ranks stayed healthy and remained ready to respond, including ordering members to sequester themselves from the general public.
These efforts would be in addition to being able to respond to other emergencies, like the widespread flooding seen around this time last year.</p>
<p>On March 23, Mayor John Tory declared an Emergency Opens in new window in the city of Toronto. The declaration of a municipal emergency PDF is part of the City’s ongoing efforts to stop the spread of COVID-19 and will ensure the municipal government can continue to act and respond quickly to the pandemic and any other events that arise in the weeks ahead.
Listen to a message from Mayor John Tory Opens in new window and hear more about the importance of staying home Opens in new window and what you can do to help.
Toronto Public Health has had 591 cases of COVID-19 reported in Toronto. Currently, 67 of these people are hospitalized and there are 30 in ICU. Among cases of COVID-19 in Toronto, there have been 6 deaths to-date. There have been 30 other people diagnosed with COVID-19 who have recovered from their illness. This data was extracted from the Integrated Public Health Information System at 1 p.m. on March 30, 2020. The numbers may differ from other sources, as data are extracted at different times.
If you think you have COVID-19 symptoms or have been in close contact with someone who has it, find out if you should visit an assessment centre and where the nearest location is.</p>
</section1>
<section1 class="full-viewport">
<blockquote>Sports: Toyko Olympics Update</blockquote>
<p>Next year’s Tokyo Olympics will now officially open on 23 July 2021 – 364 days later than planned – in order to give organisers the time needed to prepare after the disruption caused by the Covid-19 pandemic.
The decision was confirmed by the International Olympic Committee following a conference call between its president, Thomas Bach, and the international sports federations on Monday. Bach gave them one choice of a new date – 23 July to 8 August – before asking the federations for a show of support, which was unanimous.</p>
<p>The decision was confirmed by the International Olympic Committee following a conference call between its president, Thomas Bach, and the international sports federations on Monday. Bach gave them one choice of a new date – 23 July to 8 August – before asking the federations for a show of support, which was unanimous.</p>
<p>The new dates, exactly one year after those originally planned for 2020, also have the added benefit that any disruption that the postponement will cause to the international sports calendar can be kept to a minimum. Additionally, they will provide sufficient time to finish the qualification process. The same heat mitigation measures as planned for 2020 will be implemented.</p>
<p>Next year’s Tokyo Olympics will now officially open on 23 July 2021 – 364 days later than planned – in order to give organisers the time needed to prepare after the disruption caused by the Covid-19 pandemic.
The decision was confirmed by the International Olympic Committee following a conference call between its president, Thomas Bach, and the international sports federations on Monday. Bach gave them one choice of a new date – 23 July to 8 August – before asking the federations for a show of support, which was unanimous.</p>
<p>The decision was confirmed by the International Olympic Committee following a conference call between its president, Thomas Bach, and the international sports federations on Monday. Bach gave them one choice of a new date – 23 July to 8 August – before asking the federations for a show of support, which was unanimous.</p>
<p>The new dates, exactly one year after those originally planned for 2020, also have the added benefit that any disruption that the postponement will cause to the international sports calendar can be kept to a minimum. Additionally, they will provide sufficient time to finish the qualification process. The same heat mitigation measures as planned for 2020 will be implemented.</p>
</section1>
<section1 class="full-viewport">
<blockquote>Media: COVID-19 Hollywood: Idris Elba, The Witcher and GOT actor add to growing list of celebrities with coronavirus</blockquote>
<p>The novel coronavirus continues to spread across the globe, and even the world’s biggest names aren’t safe.
While many celebrities and public figures have taken to social media to stress the importance of social distancing, some have also announced their own battle with COVID-19.
Here are all the big names currently battling the illness.</p>
<p><b>Joe Prine</b></p>
<p>The family of John Prine says the singer-songwriter is critically ill and has been placed on a ventilator while being treated for COVID-19-type symptoms.</p>
<p><b>Boris Johnson</b></p>
<p>British Prime Minister Boris Johnson has tested positive for the new coronavirus, the first leader of a major nation to contract COVID-19, but he insisted Friday that he remains in charge of the U.K.’s response to the outbreak.</p>
<p><b>Tom Hanks and Rita Wilson</b></p>
<p>Hanks and Wilson were the first big celebrities to contract the virus. He shared an official statement on his social media on March 11, writing: “Rita and I are down here in Australia. We felt a bit tired, like we had colds, and some body aches … To play things right, as is needed in the world right now, we were tested for the coronavirus, and were found to be positive.”</p>
<p><b>Daniel Dae Kim</b></p>
<p>The Hawaii Five-0 actor shared a 10-minute video on Instagram on March 19, opening up about his journey to the diagnosis and telling his fans to self-isolate.
“I wanted to let you know that yesterday I tested positive for COVID-19, the disease caused by the coronavirus,” the actor said on Instagram.
Kim, who is in Hawaii and was tested for the disease there, said he was shooting the series New Amsterdam in New York before production shut down and he returned to Hawaii to be with his family.</p>
</section1>
</article>
</main>
</body>
<script src="javscript/index.js"></script>
</html>
Here is my JS:
let theStateoftheInterface = (event) => {
let winH = document.documentElement.clientHeight
let winH = document.documentElement.clientWidth
let docH = document.documentElement.scrollHeight
let docH = document.documentElement.scrollWidth
let winY = window.scrollY
let winX = window.scrollX
let maxY = docH - winH
let maxX = docW - winW
let pctY = Math.round(winY / Math.max(maxY, 1) * 100)
let pctX = Math.round(winX / Math.max(maxX, 1) * 100)
}
if (winY >= maxY) {
document.querySelector('#content').innerHTML += `
<section1 class="full-viewport">
<blockquote>Toronto's Latest News</blockquote>
</section1>`
}
im not sure whats not working .. im following my professors step by step video
I would like to capture the name of the speaker and the comment that was made. I've tried using several different variations of ([-]{5,}\s\S+), but this doesn't seem to do the tricky. Ideally, I would like to end up with the following:
var data = [
{
name: "Operator",
comment: "Ladies and gentlemen, thank you for standing by. Welcome to the 3M First Quarter Earnings Conference Call. (Operator Instructions) As a reminder, this conference is being recorded, Thursday, April 25, 2019. I would now like to turn the call over to Bruce Jermeland, Vice President of Investor Relations at 3M."
},
{
name: "Bruce Jermeland, 3M Company - Director of IR",
comment: "Thank you, and good morning, everyone. Welcome to our first quarter 2019 business review. With me today are Mike Roman, 3M's Chief Executive Officer; and Nick Gangestad, our Chief Financial Officer. Mike and Nick will make some formal comments, and then we'll take your questions. Please note that today's earnings release and slide presentation accompanying this call are posted on our Investor Relations website at 3m.com under the heading, Quarterly Earnings. Please turn to Slide 2. Before we begin, let me remind you to mark your calendars for our upcoming earnings calls on July 25 and October 24. Please take a moment to read the forward-looking statement on Slide 3. During today's conference call, we will make certain predictive statements that reflect our current views about 3M's future performance and financial results. These statements are based on certain assumptions and expectations of future events that are subject to risks and uncertainties. Item 1A of our most recent Form 10-K lists some of the most important risk factors that could cause actual results to differ from our predictions. Finally, please note that throughout today's presentation, we will be making references to certain non-GAAP financial measures, in particular, measures which exclude the impact of the Tax Cuts and Jobs Act and significant litigation-related charges. Reconciliations of the non-GAAP measures can be found in the appendix of today's presentation and press release. Please turn to Slide 4, and I'll hand it off to Mike. Mike?"
},
...
]
How can I accomplish this?
var text = `Q1 2019 3M Co Earnings Call
ST. PAUL Apr 27, 2019 (Thomson StreetEvents) -- Edited Transcript of 3M Co earnings conference call or presentation Thursday, April 25, 2019 at 1:00:00pm GMT
TEXT version of Transcript
================================================================================
Corporate Participants
================================================================================
* Bruce Jermeland
3M Company - Director of IR
* Michael F. Roman
3M Company - CEO & Director
* Nicholas C. Gangestad
3M Company - Senior VP & CFO
================================================================================
Conference Call Participants
================================================================================
* Andrew Alec Kaplowitz
Citigroup Inc, Research Division - MD and U.S. Industrial Sector Head
* Andrew Burris Obin
BofA Merrill Lynch, Research Division - MD
* Charles Stephen Tusa
JP Morgan Chase & Co, Research Division - MD
* Deane Michael Dray
RBC Capital Markets, LLC, Research Division - Analyst
* John Fred Walsh
Crédit Suisse AG, Research Division - Director
* John George Inch
Gordon Haskett Research Advisors - MD & Senior Analyst of Multi-Industrials
* Joseph Alfred Ritchie
Goldman Sachs Group Inc., Research Division - VP & Lead Multi-Industry Analyst
* Joshua Charles Pokrzywinski
Morgan Stanley, Research Division - Equity Analyst
* Julian C.H. Mitchell
Barclays Bank PLC, Research Division - Research Analyst
* Laurence Alexander
Jefferies LLC, Research Division - VP & Equity Research Analyst
* Nigel Edward Coe
Wolfe Research, LLC - MD & Senior Research Analyst
* Scott Reed Davis
Melius Research LLC - Founding Partner, Chairman, CEO & Research Analyst of Multi-Industry Research
================================================================================
Presentation
--------------------------------------------------------------------------------
Operator [1]
--------------------------------------------------------------------------------
Ladies and gentlemen, thank you for standing by. Welcome to the 3M First Quarter Earnings Conference Call. (Operator Instructions) As a reminder, this conference is being recorded, Thursday, April 25, 2019.
I would now like to turn the call over to Bruce Jermeland, Vice President of Investor Relations at 3M.
--------------------------------------------------------------------------------
Bruce Jermeland, 3M Company - Director of IR [2]
--------------------------------------------------------------------------------
Thank you, and good morning, everyone. Welcome to our first quarter 2019 business review. With me today are Mike Roman, 3M's Chief Executive Officer; and Nick Gangestad, our Chief Financial Officer. Mike and Nick will make some formal comments, and then we'll take your questions.
Please note that today's earnings release and slide presentation accompanying this call are posted on our Investor Relations website at 3m.com under the heading, Quarterly Earnings. Please turn to Slide 2.
Before we begin, let me remind you to mark your calendars for our upcoming earnings calls on July 25 and October 24. Please take a moment to read the forward-looking statement on Slide 3.
During today's conference call, we will make certain predictive statements that reflect our current views about 3M's future performance and financial results. These statements are based on certain assumptions and expectations of future events that are subject to risks and uncertainties. Item 1A of our most recent Form 10-K lists some of the most important risk factors that could cause actual results to differ from our predictions.
Finally, please note that throughout today's presentation, we will be making references to certain non-GAAP financial measures, in particular, measures which exclude the impact of the Tax Cuts and Jobs Act and significant litigation-related charges. Reconciliations of the non-GAAP measures can be found in the appendix of today's presentation and press release.
Please turn to Slide 4, and I'll hand it off to Mike. Mike?
--------------------------------------------------------------------------------
Operator [87]
--------------------------------------------------------------------------------
Ladies and gentlemen, that does conclude the conference call for today. We thank you for your participation and ask that you please disconnect your lines.`;
console.log(text);
You could use a capturing group and for the match of the speaker use a character class and specify what characters you would allow for the name and repeat that with a space in between.
Then match the line with only hyphens followed by using a second capturing group matching the following content until you encounter the next line that starts with a hyphen. (Or multiple if you want to make it more specific.
^[ \t]*(\w+(?:[ \t]+[\w,-]+)*)[\t ]+\[\d+\]\r?\n-+\s+((?:(?:\r?\n)?(?!-).*)*)
Explanation
^ Start of string
[ \t]* Match 0+ tabs/spaces
( Capture group 1
\w+(?:[ \t]+[\w,-]+)* Match 1+ word char and repeat 0+ times matching 1+ tabs/spaces and a character class where you could specify what you would allow to match.
) Close group 1
[\t ]+\[\d+\] Match 1+ tabs/spaces, the 1+ digits between [..]
\r?\n-+\s+ Match newline, 1+ times a hyphen followed by 1+ times a whitespace char (which will also match the prepended spaces before the start of the comment)
( Capture group 2
(?: Non capturing group
(?:\r?\n)?(?!-).* Match optional newline, assert what is on the right is not a hyphen, then match the rest of the line.
)* Close non capturing group and repeat 0+ times
)Close group 2
Regex demo
var str = `Q1 2019 3M Co Earnings Call
ST. PAUL Apr 27, 2019 (Thomson StreetEvents) -- Edited Transcript of 3M Co earnings conference call or presentation Thursday, April 25, 2019 at 1:00:00pm GMT
TEXT version of Transcript
================================================================================
Corporate Participants
================================================================================
* Bruce Jermeland
3M Company - Director of IR
* Michael F. Roman
3M Company - CEO & Director
* Nicholas C. Gangestad
3M Company - Senior VP & CFO
================================================================================
Conference Call Participants
================================================================================
* Andrew Alec Kaplowitz
Citigroup Inc, Research Division - MD and U.S. Industrial Sector Head
* Andrew Burris Obin
BofA Merrill Lynch, Research Division - MD
* Charles Stephen Tusa
JP Morgan Chase & Co, Research Division - MD
* Deane Michael Dray
RBC Capital Markets, LLC, Research Division - Analyst
* John Fred Walsh
Crédit Suisse AG, Research Division - Director
* John George Inch
Gordon Haskett Research Advisors - MD & Senior Analyst of Multi-Industrials
* Joseph Alfred Ritchie
Goldman Sachs Group Inc., Research Division - VP & Lead Multi-Industry Analyst
* Joshua Charles Pokrzywinski
Morgan Stanley, Research Division - Equity Analyst
* Julian C.H. Mitchell
Barclays Bank PLC, Research Division - Research Analyst
* Laurence Alexander
Jefferies LLC, Research Division - VP & Equity Research Analyst
* Nigel Edward Coe
Wolfe Research, LLC - MD & Senior Research Analyst
* Scott Reed Davis
Melius Research LLC - Founding Partner, Chairman, CEO & Research Analyst of Multi-Industry Research
================================================================================
Presentation
--------------------------------------------------------------------------------
Operator [1]
--------------------------------------------------------------------------------
Ladies and gentlemen, thank you for standing by. Welcome to the 3M First Quarter Earnings Conference Call. (Operator Instructions) As a reminder, this conference is being recorded, Thursday, April 25, 2019.
I would now like to turn the call over to Bruce Jermeland, Vice President of Investor Relations at 3M.
--------------------------------------------------------------------------------
Bruce Jermeland, 3M Company - Director of IR [2]
--------------------------------------------------------------------------------
Thank you, and good morning, everyone. Welcome to our first quarter 2019 business review. With me today are Mike Roman, 3M's Chief Executive Officer; and Nick Gangestad, our Chief Financial Officer. Mike and Nick will make some formal comments, and then we'll take your questions.
Please note that today's earnings release and slide presentation accompanying this call are posted on our Investor Relations website at 3m.com under the heading, Quarterly Earnings. Please turn to Slide 2.
Before we begin, let me remind you to mark your calendars for our upcoming earnings calls on July 25 and October 24. Please take a moment to read the forward-looking statement on Slide 3.
During today's conference call, we will make certain predictive statements that reflect our current views about 3M's future performance and financial results. These statements are based on certain assumptions and expectations of future events that are subject to risks and uncertainties. Item 1A of our most recent Form 10-K lists some of the most important risk factors that could cause actual results to differ from our predictions.
Finally, please note that throughout today's presentation, we will be making references to certain non-GAAP financial measures, in particular, measures which exclude the impact of the Tax Cuts and Jobs Act and significant litigation-related charges. Reconciliations of the non-GAAP measures can be found in the appendix of today's presentation and press release.
Please turn to Slide 4, and I'll hand it off to Mike. Mike?
--------------------------------------------------------------------------------
Operator [87]
--------------------------------------------------------------------------------
Ladies and gentlemen, that does conclude the conference call for today. We thank you for your participation and ask that you please disconnect your lines.`;
var m;
var data = [];
var regex = /^[ \t]*(\w+(?:[ \t]+[\w,-]+)*)[\t ]+\[\d+\]\r?\n-+\s+((?:(?:\r?\n)?(?!-).*)*)/mg;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
data.push({
"name": m[1],
"comment": m[2]
});
}
console.log(data);
Seems like you can just split by /-{5,}/ and trim the parts :
var text = `Q1 2019 3M Co Earnings Call
ST. PAUL Apr 27, 2019 (Thomson StreetEvents) -- Edited Transcript of 3M Co earnings conference call or presentation Thursday, April 25, 2019 at 1:00:00pm GMT
TEXT version of Transcript
================================================================================
Corporate Participants
================================================================================
* Bruce Jermeland
3M Company - Director of IR
* Michael F. Roman
3M Company - CEO & Director
* Nicholas C. Gangestad
3M Company - Senior VP & CFO
================================================================================
Conference Call Participants
================================================================================
* Andrew Alec Kaplowitz
Citigroup Inc, Research Division - MD and U.S. Industrial Sector Head
* Andrew Burris Obin
BofA Merrill Lynch, Research Division - MD
* Charles Stephen Tusa
JP Morgan Chase & Co, Research Division - MD
* Deane Michael Dray
RBC Capital Markets, LLC, Research Division - Analyst
* John Fred Walsh
Crédit Suisse AG, Research Division - Director
* John George Inch
Gordon Haskett Research Advisors - MD & Senior Analyst of Multi-Industrials
* Joseph Alfred Ritchie
Goldman Sachs Group Inc., Research Division - VP & Lead Multi-Industry Analyst
* Joshua Charles Pokrzywinski
Morgan Stanley, Research Division - Equity Analyst
* Julian C.H. Mitchell
Barclays Bank PLC, Research Division - Research Analyst
* Laurence Alexander
Jefferies LLC, Research Division - VP & Equity Research Analyst
* Nigel Edward Coe
Wolfe Research, LLC - MD & Senior Research Analyst
* Scott Reed Davis
Melius Research LLC - Founding Partner, Chairman, CEO & Research Analyst of Multi-Industry Research
================================================================================
Presentation
--------------------------------------------------------------------------------
Operator [1]
--------------------------------------------------------------------------------
Ladies and gentlemen, thank you for standing by. Welcome to the 3M First Quarter Earnings Conference Call. (Operator Instructions) As a reminder, this conference is being recorded, Thursday, April 25, 2019.
I would now like to turn the call over to Bruce Jermeland, Vice President of Investor Relations at 3M.
--------------------------------------------------------------------------------
Bruce Jermeland, 3M Company - Director of IR [2]
--------------------------------------------------------------------------------
Thank you, and good morning, everyone. Welcome to our first quarter 2019 business review. With me today are Mike Roman, 3M's Chief Executive Officer; and Nick Gangestad, our Chief Financial Officer. Mike and Nick will make some formal comments, and then we'll take your questions.
Please note that today's earnings release and slide presentation accompanying this call are posted on our Investor Relations website at 3m.com under the heading, Quarterly Earnings. Please turn to Slide 2.
Before we begin, let me remind you to mark your calendars for our upcoming earnings calls on July 25 and October 24. Please take a moment to read the forward-looking statement on Slide 3.
During today's conference call, we will make certain predictive statements that reflect our current views about 3M's future performance and financial results. These statements are based on certain assumptions and expectations of future events that are subject to risks and uncertainties. Item 1A of our most recent Form 10-K lists some of the most important risk factors that could cause actual results to differ from our predictions.
Finally, please note that throughout today's presentation, we will be making references to certain non-GAAP financial measures, in particular, measures which exclude the impact of the Tax Cuts and Jobs Act and significant litigation-related charges. Reconciliations of the non-GAAP measures can be found in the appendix of today's presentation and press release.
Please turn to Slide 4, and I'll hand it off to Mike. Mike?
--------------------------------------------------------------------------------
Operator [87]
--------------------------------------------------------------------------------
Ladies and gentlemen, that does conclude the conference call for today. We thank you for your participation and ask that you please disconnect your lines.`;
var data = [], parts = text.split(/-{5,}/);
for (var i = 1; i < parts.length; i += 2)
data.push({ name: parts[i].split('[')[0].trim(), comment: parts[i + 1].trim() });
console.log(data);
A regex like /-{5,}(.*?)-{5,}(.*?)(?:-{5}|$)/gs will capture both the speaker and the spoken text (it will only break if the spoken text / speaker name contain more then 4 dashes after each other -----)
regex101 demo
Explanation:
-{5,} will match the first row of ----s, before the speaker name
(.*?) captures the speaker name
-{5,} matches the second row of ----s, the separator between speaker <-> spoken text
(.*?) captures the spoken text
(?:-{5}|$) matches either the end of the file or five dashes -----. (this leaves enough dashes for the first part of this regex to match again for the next speaker)
Example:
function sanitizeName(name) {
// trim it and remove the " [12]" after the name
return name.replace(/\s*\[\d+\]\s*$/, '').trim();
}
function parseConversation(text) {
let regex = /-{5,}(.*?)-{5,}(.*?)(?:-{5}|$)/gs;
let lines = [];
let match;
do {
match = regex.exec(text);
if (match) {
lines.push({
name: sanitizeName(match[1]),
comment: match[2].trim()
});
}
} while (match);
return lines;
}
let text = `Q1 2019 3M Co Earnings Call
ST. PAUL Apr 27, 2019 (Thomson StreetEvents) -- Edited Transcript of 3M Co earnings conference call or presentation Thursday, April 25, 2019 at 1:00:00pm GMT
TEXT version of Transcript
================================================================================
Corporate Participants
================================================================================
* Bruce Jermeland
3M Company - Director of IR
* Michael F. Roman
3M Company - CEO & Director
* Nicholas C. Gangestad
3M Company - Senior VP & CFO
================================================================================
Conference Call Participants
================================================================================
* Andrew Alec Kaplowitz
Citigroup Inc, Research Division - MD and U.S. Industrial Sector Head
* Andrew Burris Obin
BofA Merrill Lynch, Research Division - MD
* Charles Stephen Tusa
JP Morgan Chase & Co, Research Division - MD
* Deane Michael Dray
RBC Capital Markets, LLC, Research Division - Analyst
* John Fred Walsh
Crédit Suisse AG, Research Division - Director
* John George Inch
Gordon Haskett Research Advisors - MD & Senior Analyst of Multi-Industrials
* Joseph Alfred Ritchie
Goldman Sachs Group Inc., Research Division - VP & Lead Multi-Industry Analyst
* Joshua Charles Pokrzywinski
Morgan Stanley, Research Division - Equity Analyst
* Julian C.H. Mitchell
Barclays Bank PLC, Research Division - Research Analyst
* Laurence Alexander
Jefferies LLC, Research Division - VP & Equity Research Analyst
* Nigel Edward Coe
Wolfe Research, LLC - MD & Senior Research Analyst
* Scott Reed Davis
Melius Research LLC - Founding Partner, Chairman, CEO & Research Analyst of Multi-Industry Research
================================================================================
Presentation
--------------------------------------------------------------------------------
Operator [1]
--------------------------------------------------------------------------------
Ladies and gentlemen, thank you for standing by. Welcome to the 3M First Quarter Earnings Conference Call. (Operator Instructions) As a reminder, this conference is being recorded, Thursday, April 25, 2019.
I would now like to turn the call over to Bruce Jermeland, Vice President of Investor Relations at 3M.
--------------------------------------------------------------------------------
Bruce Jermeland, 3M Company - Director of IR [2]
--------------------------------------------------------------------------------
Thank you, and good morning, everyone. Welcome to our first quarter 2019 business review. With me today are Mike Roman, 3M's Chief Executive Officer; and Nick Gangestad, our Chief Financial Officer. Mike and Nick will make some formal comments, and then we'll take your questions.
Please note that today's earnings release and slide presentation accompanying this call are posted on our Investor Relations website at 3m.com under the heading, Quarterly Earnings. Please turn to Slide 2.
Before we begin, let me remind you to mark your calendars for our upcoming earnings calls on July 25 and October 24. Please take a moment to read the forward-looking statement on Slide 3.
During today's conference call, we will make certain predictive statements that reflect our current views about 3M's future performance and financial results. These statements are based on certain assumptions and expectations of future events that are subject to risks and uncertainties. Item 1A of our most recent Form 10-K lists some of the most important risk factors that could cause actual results to differ from our predictions.
Finally, please note that throughout today's presentation, we will be making references to certain non-GAAP financial measures, in particular, measures which exclude the impact of the Tax Cuts and Jobs Act and significant litigation-related charges. Reconciliations of the non-GAAP measures can be found in the appendix of today's presentation and press release.
Please turn to Slide 4, and I'll hand it off to Mike. Mike?
--------------------------------------------------------------------------------
Operator [87]
--------------------------------------------------------------------------------
Ladies and gentlemen, that does conclude the conference call for today. We thank you for your participation and ask that you please disconnect your lines.`;
console.log(parseConversation(text));
i have data in the below format, is not a valid json and am trying to convert using regex, for details see this question which i've tried, but the parse won't go through.
The problem is that the response string also contains html, var and trailing commas. below is the failing test data.
The expected output should be a valid JSON to use in the rest of my application
I do not have any control over modifying the server response.
`var _nr_metadata = {
site_base_url : "http://newsrack.in",
issue_name : "iihs_feeds",
category_name : "Chikungunya",
listing_url : "/stories/servelots/iihs_feeds/16"
}
var _nr_stories = [
{
title : "Alarm bells ringing:194 dengue cases in 2 weeks in district",
url : "http://www.tribuneindia.com/news/ludhiana/alarm-bells-ringing-194-dengue-cases-in-2-weeks-in-district/486718.html",
source : "The Tribune",
date : "25.10.2017",
desc : "Tribune News Service\nLudhiana, October 24\nThe number of dengue cases is rapidly increasing in the district as 194 confirmed cases have been recorded by the Health Department in the past two weeks.\nA total of 309 confirmed cases and 524 suspected cases of dengue have been reported in the district this year till Monday. According to the Health Department, cases are mostly being reported from the areas on Chandigarh Road in Ludhiana. These include 33-foot Road, GTB Nagar, Mundian Kalan, Guru Nanak Nagar, GK Estate, Jamalpur, Sectors 32 and 39. There are chances that the number of dengue cases could be higher than official reports, say residents.\nThe department had recorded 31 confirmed dengue cases till September 22 and 115 cases till October 10 in these places. Apart from these cases, as many as 10 confirmed cases of chikungunya, which is also spread by bite of infected aedes mosquitoes, have been reported here this year.\nHealth team finds mosquito larvae in 438 containers\nHealth Inspector Manpreet Singh ..."
},
{
title : "650 new cases of dengue, 48 of chikungunya",
url : "http://www.thehindu.com/news/cities/Delhi/650-new-cases-of-dengue-48-of-chikungunya/article19908528.ece",
source : "Hindu: Cities",
date : "24.10.2017",
desc : "More than 1,000 dengue cases reported so far this month"
},
{
title : "Dengue cases mount to 5,870 in Delhi",
url : "http://indianexpress.com/article/cities/delhi/dengue-cases-mount-to-5870-in-delhi-this-season-4903035/",
source : "Delhi – The Indian Express",
date : "23.10.2017",
desc : "<img alt=\"\" border=\"0\" src=\"http://pixel.wp.com/b.gif?host=indianexpress.com&blog=53855017&post=4903035&subd=indianexpressonline&ref=&feed=1\" width=\"1\" height=\"1\" />"
},
{
title : "Nilavembu Kudineer safe, efficacious, confirms National Institute of Siddha",
url : "http://www.deccanchronicle.com/lifestyle/health-and-wellbeing/221017/nilavembu-kudineer-safe-efficacious-confirms-national-institute-of-siddha.html",
source : "",
date : "22.10.2017",
desc : "Chennai: Nilavembu Kudineer is safe and effective to treat dengue and other viral fevers and one need not have any qualms in consuming this herbal concoction for immediate relief, the National Institute of Siddha (NIS) functioning under the Union Ayush ministry, here has assured. This institute plans to take up a full-fledged study for global reach of this traditional medicine.\nNilavembu kashayam has been in use for over half-a-century at Government Siddha Medical College, Palayamkottai. It is one among the 32 types of internal medicines described in the Siddha system of medicine. "The nilavembu kudineer, now used for the prevention and management of dengue fever has been explained in the Siddha literatures several centuries ago. There are many research papers on nilavembu kudineer for the treatment and prevention of dengue and other viral diseases. Based on the research studies conducted by our National Institute of Siddha, 70 per cent prevention has been proven against dengue and other viral ..."
},
{
title : "Dengue count hits 902 in city",
url : "http://www.tribuneindia.com/news/chandigarh/dengue-count-hits-902-in-city/485318.html",
source : "The Tribune",
date : "22.10.2017",
desc : "Tribune News Service\nChandigarh, October 21\nWith two deaths at city hospitals, the number of dengue patients has touched 902. According to the Heath Department, the dengue threat will stay for next fortnight.\nDr Gaurav Aggarwal, anti-malaria officer, said 61 malaria and 58 chikungunya cases had also been reported. Last year, the dengue count in the city was 1,246.\n“Next 15 days are crucial. Residents need to be cautious. The weather is congenial for the breeding of aedes aegypti mosquitoes that cause dengue. As the days progress, dengue cases will start declining,” said Dr Gaurav Aggarwal.\nHe added dengue cases were reported from densely populated areas in Dhanas, Ram Darbar, Daddu Majra, Burail besides Sectors 15 and 25. “Since it is a notifiable disease, the hospitals will have to inform the UT Heath Department within 24 hours,” said Dr Aggarwal. The Heath Department is planning to take strict action against the hospitals for any kind of laxity on their part. “First, we will sent them a notice. It ..."
},
{
title : "‘Nilavembu kudineer’, a much sought-after elixir",
url : "http://www.thehindu.com/news/national/tamil-nadu/nilavembu-kudineer-a-much-sought-after-elixir/article19894225.ece",
source : "Hindu: National",
date : "21.10.2017",
desc : "GSMCH has served it to 8.63 lakh persons this year"
},
{
title : "Two more succumb to vector-borne disease",
url : "http://www.tribuneindia.com/news/delhi/dengue-sting/484758.html",
source : "The Tribune",
date : "21.10.2017",
desc : "Tribune News Service\nNew Delhi, October 20\nTwo more persons have fallen prey to dengue in the national Capital taking the tally of deaths from the vector-borne disease this season to five.\nThe last two fatalities took place at city government-run Lok Nayak Jayaprakash (LNJP) Hospital which has alone reported over 860 cases of dengue and two deaths.\nAccording to the latest municipal report, tabulated by the South Delhi Municipal Corporation, the number of people affected by the mosquito -borne disease this season till October 14 has reached 5,220.\nA 12-year-old boy, who died due to dengue shock syndrome at the Sir Ganga Ram Hospital on August, was the first victim in the Capital this year. Of the total 5,220 positive cases of dengue, 2,564 were residents of Delhi whereas the rest were from other states. Of the 2,564 Delhi cases, 757 were reported this month, as per the civic body.\nSimilarly till October 14 the figures of malaria and chikungunya stood at 1062 and 683 respectively. According to the report, ..."
},
{
title : "Over 23 per cent of susceptible population gets infected",
url : "http://www.deccanchronicle.com/nation/politics/201017/over-23-per-cent-of-susceptible-population-gets-infected.html",
source : "",
date : "20.10.2017",
desc : "Chennai: Dengue has generated much attention and debate, as well, but it appears to be rather difficult to manage this menace without collective efforts, it appears.\nAlthough several Opposition parties including the DMK, BJP and even the PMK, in a rare show of social commitment, launched the preventive measures to help bring down the prevalence, as per an estimate 23 per cent of susceptible population in Chennai gets affected by dengue every year.\nAs per a study published in the PLOS journal: Hidden burden of Dengue in Chennai, in 2015, over 93 per cent of the population is affected. "Going by a conservative estimate let's assume that there is only one per cent of deaths, even then, there will be 2,880 deaths per year in Chennai alone. So, this is the reality. When people have already conducted a study and the conservative estimate is 2,880 as per the article, we need to devise appropriate measures to tackle the menace," claims Dr V. Pugazhenthi of Doctors for Safe Environment (Dose).\nThe ..."
},
{
title : "Dengue in Jammu: 88 test positive in 11 days; 336 cases reported since July",
url : "http://www.business-standard.com/article/current-affairs/dengue-in-jammu-88-test-positive-in-11-days-336-cases-reported-since-july-117101800395_1.html",
source : "Business Standard: News Now",
date : "18.10.2017",
desc : "As many as 88 people were tested positive for dengue during the past 11 days here, taking the total number of such patients in the state since July to 336, officials said.\nOut of the 88 tested positive for dengue since October 7, 71 are residents of the Jammu district, seven of Sabma, six Kathua, two Udhampur and one each of Rajouri and Doda districts, they said.\nAt 292, Jammu has recorded the highest number of cases since July, when it was first reported this year.\nIt was followed by Kathua (12), Samba (11), Rajouri, Udhampur, Doda (six each), and Poonch and Kishtwar (one each), the officials said.\nThey said one case of dengue was reported from Kashmir.\nThe officials said 2,023 tests were conducted till yesterday and so far 336 people including 111 children and 84 women were tested positive for dengue, while 268 reports are still awaited.\nHowever, there was no fresh case of swine flu which claimed three lives in the Jammu region since July, the officials said.\nHea"
},
{
title : "Plethora of diseases threaten to mar festivities",
url : "http://www.thehindu.com/news/cities/Delhi/plethora-of-diseases-threaten-to-mar-festivities/article19880477.ece",
source : "Hindu: News",
date : "18.10.2017",
desc : "Doctors ask people to stay away from Diwali pollution, urge them to take precautionary measures"
},
{
title : "No side effects in Nilavembu: TN health minister",
url : "http://www.deccanchronicle.com/nation/current-affairs/181017/no-side-effects-in-nilavembu-tn-health-minister.html",
source : "",
date : "18.10.2017",
desc : "Chennai: Rubbishing the reports in a section of the media that Nilavembu kashayam causes infertility, state health minister Dr Vijayabaskar on Tuesday insisted that the herbal decoction has been tested scientifically and proved effective against several types of fevers, including Dengue and Chickungunya.\n"People should not believe in baseless rumours that Nilavembu kashayam will cause side effects. This herbal medicine has been tested well and used widely in many countries", the minister said, responding to reports in a section of the media that the use of this medicine could lead to infertility.\nElaborating on the good caused by the herbal medicine in the treatment of fevers, the minister said it had been approved for public use by Jayalalithaa during her tenure as Chief Minister when Chickungunya broke out.\n"We will continue to make elaborate arrangements to distribute Nilavembu kudineer to the public. Also, the government hospitals have been instructed to ensure proper hydration of ..."
},
{
title : "Dengue cases in Hyderabad on rise due to continuous rainfall",
url : "http://www.deccanchronicle.com/nation/current-affairs/171017/dengue-cases-in-hyderabad-on-rise-due-to-continuous-rainfall.html",
source : "",
date : "17.10.2017",
desc : "<p><strong>Hyderabad:<\/strong> Continuous rainfall over the past few days has sent dengue numbers soaring in Hyderabad, doctors said, on Tuesday.<\/p><p>"There are a lot of Chikungunya and dengue cases and continuous rain has given way to viral flu," said a doctor at a local hospital, Doctor Shankar.<\/p><p>He added that the stagnant water has led to mosquito breeding, thus, further aggravating the problem.<\/p><p>One of the patients at a hospital said many people have been complaining of health issues due to the weather change.<\/p><p>"My child is suffering from fever from the past one week, people are unable to use roads due to severe waterlogging and there is heavy traffic," said a resident.<\/p>"
},
{
title : "Bengaluru: First came the deluge, now comes the disease",
url : "http://www.deccanchronicle.com/lifestyle/health-and-wellbeing/171017/first-came-the-deluge-now-comes-the-disease.html",
source : "",
date : "17.10.2017",
desc : "With the rains showing no signs of letting up, there has been an outbreak of vector-borne and water-borne diseases across the city. There have been 4,990 cases of dengue and 116 cases of chikungunya since January in Bengaluru alone. Experts blame it on the lack of awareness among people and the general apathy of the BBMP when it comes to keeping the city clean. The problem needs to be dealt with on a war footing. Joyeeta Chakravorty and Chandrashekar G report.\nFirst the deluge and then the disease. Having received a record rainfall, the highest in 115 years this monsoon, which has left its roads and homes flooded and even washed away a few people , Bengaluru is now witnessing the inevitable outbreak of disease. With rain water refusing to run off in some localities with their blocked drains and large potholes, there is a bigger than usual influx of mosquitoes and a spike in vector-borne diseases like dengue and chikungunya. People are also coming down with gastroenteritis, typhoid and jaundice, leaving ..."
},
{
title : "Dengue claims two more lives",
url : "http://www.thehindu.com/news/cities/Delhi/dengue-claims-two-more-lives/article19873788.ece",
source : "Hindu: News",
date : "17.10.2017",
desc : "Two more persons, including a 26-year-old Manipuri woman, have succumbed to dengue in the Capital, even as the number of people affected by the vector-borne disease this season has risen to 5,220, as..."
},
{
title : "Vector-borne diseases spread tentacles",
url : "http://www.tribuneindia.com/news/punjab/vector-borne-diseases-spread-tentacles/483293.html",
source : "The Tribune",
date : "17.10.2017",
desc : "<p>Chandigarh, October 16\n<\/p><p>Dengue and chikungunya have started tightening their grip around Punjab with a large number of cases being reported from the state in the past two months.\n<\/p><p>According to the latest statistics compiled by the Department of Health and Family Welfare, so far more than 3,500 confirmed cases of dengue have been reported. Besides, around 9,000 suspected cases of dengue have also been reported in this season so far. — TNS <\/p>"
},
{
title : "Dengue snuffs out two more lives",
url : "http://www.tribuneindia.com/news/delhi/dengue-snuffs-out-two-more-lives/483238.html",
source : "The Tribune",
date : "17.10.2017",
desc : "Tribune News Service\nNew Delhi, October 16\nTwo more persons, including a 26 -year-old Manipuri woman, have succumbed to dengue in the city even as the number of people affected by the vector-borne disease this season has reached 5,220, according to a municipal report released today.\nThe mosquito-borne tropical disease had claimed its first victim in the city this year, when a 12-year-old boy died of dengue shock syndrome at Sir Ganga Ram Hospital (SGRH) on August 1.\nRhoda Daimai, who was living in Sarita Vihar, South Delhi, died on August 27 of septicaemia and other ensuing complications while 49-year-old Meena Devi, hailing from Bihar, died of dengue on September 2, the report said.\nCivic bodies said Daimai was a resident of a village in Manipur and had come to Delhi seeking treatment while Meena lived in Karawal Nagar in East Delhi. While Meena also died at SGRH, Rhoda succumbed at Holy Family Hospital.\nThe number of malaria and chikungunya cases recorded in the city till October 14 at 1,062 and 683, ..."
},
{
title : "33 new dengue cases",
url : "http://www.tribuneindia.com/news/ludhiana/33-new-dengue-cases/481972.html",
source : "The Tribune",
date : "14.10.2017",
desc : "<p>Tribune News Service\n<\/p><p>\n<\/p><p>Ludhiana, October 13\n<\/p><p>As many as 33 fresh dengue cases have surfaced from the city. The total count of confirmed dengue patients has now gone up to 183. The high-risk area from where the maximum cases are being reported is Mundian. Two new cases of chikungunya have also been confirmed.\n<\/p><p>District epidemiologist, Dr Ramesh, said people should be careful. They should not let water collect in and around their houses, he added.\n<\/p><p>“We are regularly educating people regarding symptoms and precautions of dengue. Stress is being laid in the high-risk areas. One can report a suspected case of dengue to nearest government dispensary/hospital or at the Civil Surgeon Office control room phone No. 0161-2444193,” he said. \n<\/p><p> “Test for dengue is being done free of cost at the Civil Hospital in the city,” he added. <\/p>"
},
{
title : "Delhi district courts lawyers will go on strike tomorrow",
url : "http://www.business-standard.com/article/current-affairs/delhi-district-courts-lawyers-will-go-on-strike-tomorrow-117101200359_1.html",
source : "Business Standard: News Now",
date : "12.10.2017",
desc : "The lawyers of all six district courts in the national capital will go on a day-long strike tomorrow to protest against alleged misconduct of some judges.\n\"The reasons for calling a complete strike are misconduct of judges with litigants and huge corruption in the judiciary. We have already given the names of erring judges to the High Court but no action has been taken so far,\" advocate Jaiveer Singh Chauhan, Secretary General of the coordination committee of Delhi bar associations, said.\nIn a unanimous resolution adopted by the Coordination Committee of all District Court Bar Associations here, it was alleged that some judges were repeatedly misbehaving with the lawyers by treating them as subordinates.\nThe strike is likely to paralyse work in all six district courts at Patiala House, Rohini, Saket, Tis Hazari, Dwarka and Karkardooma.\nYesterday, the lawyers at the Tis Hazari Court had also gone on a strike to protest against the alleged \"rude behaviour\" of a ..."
},
{
title : "Nuh residents to get free insecticide nets",
url : "http://www.tribuneindia.com/news/haryana/nuh-residents-to-get-free-insecticide-nets/480811.html",
source : "The Tribune",
date : "12.10.2017",
desc : "<p>Nuh residents to get free insecticide nets<\/p>\n\n<p>Chandigarh, October 11<\/p>\n\n<p>Health Minister Anil Vij said that 1.74 lakh insecticide nets would be given away free of cost to control vector-borne diseases in Nuh district. As many as 142 high-risk villages have been identified for this purpose.<\/p>\n\n<p>The minister said that insecticide nets had been received from the Central Government and soon they would be distributed among residents. He said that due to proximity to Delhi, cases of malaria were found to be more in Mewat area as compared to other areas of the state during recent years.<\/p>\n\n<p>Vij said that 72,000 RDT kits had also been sent to Nuh district for rapid testing of blood in case of diseases such as malaria, chikungunya, dengue and others. “The report of the test conducted on RDT kits can be obtained in 15-20 minutes. As per requirement, such kits have also been provided to Palwal and Yamunanagar districts,” he said.—TNS<\/p>"
},
{
title : "Vector-borne diseases keep Health Dept on toes",
url : "http://www.tribuneindia.com/news/chandigarh/vector-borne-diseases-keep-health-dept-on-toes/479936.html",
source : "The Tribune",
date : "10.10.2017",
desc : "Tribune News Service\nPatiala, October 9 \nWith the rise in the number of dengue and chikungunya cases, the possibility of an outbreak of these two diseases looms large over Patiala. \nAs many as 366 cases of dengue and 61 cases of chikungunya were reported in the district, which is now keeping the Patiala Health Department on its toes. While dengue cases have started coming in from July, chikungunya cases have been reported from August onwards. \nThough the Health Department has already deployed a rapid response team and a surveillance team in the city to treat patients, the increasing number has become a cause of concern for the authorities. Now, they are taking precautionary measures to ensure that the diseases do not spread in other areas. \nDistrict Epidemiologist Dr Gurmanjeet Kaur said, “Dengue and chikungunya tests are done free of cost at government hospitals. Patients get treatment free of cost.” \nShe said the department had already carried out fogging in areas and the affected persons were getting ..."
},
'' // Last item -- needed because previous item ends with a comma
]`
That server is in no way a JSON API, it's just churning out some JavaScript. Even a tiny change to the response format (such as using semi-colons to end statements) could break an attempt to parse it. I don't know your use case but this all seems like a bad idea to me.
All that said, trying to parse it using JSON.parse sounds a lot less dangerous than most of the alternatives. These replaces got it to parse for me:
var text = document.getElementById('response').innerText;
// 1. Convert vars to properties
text = text.replace(/^\s*var\s+(\w+)\s*=/gm, ',"$1":');
// 2. Quote the keys
text = text.replace(/^\s*(\w+)\s*:/gm, '"$1":');
// 3. Get rid of the '' at the end
text = text.replace(/^\s*\},[\n\s]*''.*$/gm, '}');
// 4. Remove the comma that step 1 added at the start
text = text.replace(/^\s*,/g, '');
// 5. Wrap everything in an object
text = '{' + text + '}';
var obj = JSON.parse(text);
console.log(obj);
<script id="response" type="custom">
var _nr_metadata = {
site_base_url : "http://newsrack.in",
issue_name : "iihs_feeds",
category_name : "Chikungunya",
listing_url : "/stories/servelots/iihs_feeds/16"
}
var _nr_stories = [
{
title : "Alarm bells ringing:194 dengue cases in 2 weeks in district",
url : "http://www.tribuneindia.com/news/ludhiana/alarm-bells-ringing-194-dengue-cases-in-2-weeks-in-district/486718.html",
source : "The Tribune",
date : "25.10.2017",
desc : "Tribune News Service\nLudhiana, October 24\nThe number of dengue cases is rapidly increasing in the district as 194 confirmed cases have been recorded by the Health Department in the past two weeks.\nA total of 309 confirmed cases and 524 suspected cases of dengue have been reported in the district this year till Monday. According to the Health Department, cases are mostly being reported from the areas on Chandigarh Road in Ludhiana. These include 33-foot Road, GTB Nagar, Mundian Kalan, Guru Nanak Nagar, GK Estate, Jamalpur, Sectors 32 and 39. There are chances that the number of dengue cases could be higher than official reports, say residents.\nThe department had recorded 31 confirmed dengue cases till September 22 and 115 cases till October 10 in these places. Apart from these cases, as many as 10 confirmed cases of chikungunya, which is also spread by bite of infected aedes mosquitoes, have been reported here this year.\nHealth team finds mosquito larvae in 438 containers\nHealth Inspector Manpreet Singh ..."
},
{
title : "650 new cases of dengue, 48 of chikungunya",
url : "http://www.thehindu.com/news/cities/Delhi/650-new-cases-of-dengue-48-of-chikungunya/article19908528.ece",
source : "Hindu: Cities",
date : "24.10.2017",
desc : "More than 1,000 dengue cases reported so far this month"
},
{
title : "Dengue cases mount to 5,870 in Delhi",
url : "http://indianexpress.com/article/cities/delhi/dengue-cases-mount-to-5870-in-delhi-this-season-4903035/",
source : "Delhi – The Indian Express",
date : "23.10.2017",
desc : "<img alt=\"\" border=\"0\" src=\"http://pixel.wp.com/b.gif?host=indianexpress.com&blog=53855017&post=4903035&subd=indianexpressonline&ref=&feed=1\" width=\"1\" height=\"1\" />"
},
{
title : "Nilavembu Kudineer safe, efficacious, confirms National Institute of Siddha",
url : "http://www.deccanchronicle.com/lifestyle/health-and-wellbeing/221017/nilavembu-kudineer-safe-efficacious-confirms-national-institute-of-siddha.html",
source : "",
date : "22.10.2017",
desc : "Chennai: Nilavembu Kudineer is safe and effective to treat dengue and other viral fevers and one need not have any qualms in consuming this herbal concoction for immediate relief, the National Institute of Siddha (NIS) functioning under the Union Ayush ministry, here has assured. This institute plans to take up a full-fledged study for global reach of this traditional medicine.\nNilavembu kashayam has been in use for over half-a-century at Government Siddha Medical College, Palayamkottai. It is one among the 32 types of internal medicines described in the Siddha system of medicine. "The nilavembu kudineer, now used for the prevention and management of dengue fever has been explained in the Siddha literatures several centuries ago. There are many research papers on nilavembu kudineer for the treatment and prevention of dengue and other viral diseases. Based on the research studies conducted by our National Institute of Siddha, 70 per cent prevention has been proven against dengue and other viral ..."
},
{
title : "Dengue count hits 902 in city",
url : "http://www.tribuneindia.com/news/chandigarh/dengue-count-hits-902-in-city/485318.html",
source : "The Tribune",
date : "22.10.2017",
desc : "Tribune News Service\nChandigarh, October 21\nWith two deaths at city hospitals, the number of dengue patients has touched 902. According to the Heath Department, the dengue threat will stay for next fortnight.\nDr Gaurav Aggarwal, anti-malaria officer, said 61 malaria and 58 chikungunya cases had also been reported. Last year, the dengue count in the city was 1,246.\n“Next 15 days are crucial. Residents need to be cautious. The weather is congenial for the breeding of aedes aegypti mosquitoes that cause dengue. As the days progress, dengue cases will start declining,” said Dr Gaurav Aggarwal.\nHe added dengue cases were reported from densely populated areas in Dhanas, Ram Darbar, Daddu Majra, Burail besides Sectors 15 and 25. “Since it is a notifiable disease, the hospitals will have to inform the UT Heath Department within 24 hours,” said Dr Aggarwal. The Heath Department is planning to take strict action against the hospitals for any kind of laxity on their part. “First, we will sent them a notice. It ..."
},
{
title : "‘Nilavembu kudineer’, a much sought-after elixir",
url : "http://www.thehindu.com/news/national/tamil-nadu/nilavembu-kudineer-a-much-sought-after-elixir/article19894225.ece",
source : "Hindu: National",
date : "21.10.2017",
desc : "GSMCH has served it to 8.63 lakh persons this year"
},
{
title : "Two more succumb to vector-borne disease",
url : "http://www.tribuneindia.com/news/delhi/dengue-sting/484758.html",
source : "The Tribune",
date : "21.10.2017",
desc : "Tribune News Service\nNew Delhi, October 20\nTwo more persons have fallen prey to dengue in the national Capital taking the tally of deaths from the vector-borne disease this season to five.\nThe last two fatalities took place at city government-run Lok Nayak Jayaprakash (LNJP) Hospital which has alone reported over 860 cases of dengue and two deaths.\nAccording to the latest municipal report, tabulated by the South Delhi Municipal Corporation, the number of people affected by the mosquito -borne disease this season till October 14 has reached 5,220.\nA 12-year-old boy, who died due to dengue shock syndrome at the Sir Ganga Ram Hospital on August, was the first victim in the Capital this year. Of the total 5,220 positive cases of dengue, 2,564 were residents of Delhi whereas the rest were from other states. Of the 2,564 Delhi cases, 757 were reported this month, as per the civic body.\nSimilarly till October 14 the figures of malaria and chikungunya stood at 1062 and 683 respectively. According to the report, ..."
},
{
title : "Over 23 per cent of susceptible population gets infected",
url : "http://www.deccanchronicle.com/nation/politics/201017/over-23-per-cent-of-susceptible-population-gets-infected.html",
source : "",
date : "20.10.2017",
desc : "Chennai: Dengue has generated much attention and debate, as well, but it appears to be rather difficult to manage this menace without collective efforts, it appears.\nAlthough several Opposition parties including the DMK, BJP and even the PMK, in a rare show of social commitment, launched the preventive measures to help bring down the prevalence, as per an estimate 23 per cent of susceptible population in Chennai gets affected by dengue every year.\nAs per a study published in the PLOS journal: Hidden burden of Dengue in Chennai, in 2015, over 93 per cent of the population is affected. "Going by a conservative estimate let's assume that there is only one per cent of deaths, even then, there will be 2,880 deaths per year in Chennai alone. So, this is the reality. When people have already conducted a study and the conservative estimate is 2,880 as per the article, we need to devise appropriate measures to tackle the menace," claims Dr V. Pugazhenthi of Doctors for Safe Environment (Dose).\nThe ..."
},
{
title : "Dengue in Jammu: 88 test positive in 11 days; 336 cases reported since July",
url : "http://www.business-standard.com/article/current-affairs/dengue-in-jammu-88-test-positive-in-11-days-336-cases-reported-since-july-117101800395_1.html",
source : "Business Standard: News Now",
date : "18.10.2017",
desc : "As many as 88 people were tested positive for dengue during the past 11 days here, taking the total number of such patients in the state since July to 336, officials said.\nOut of the 88 tested positive for dengue since October 7, 71 are residents of the Jammu district, seven of Sabma, six Kathua, two Udhampur and one each of Rajouri and Doda districts, they said.\nAt 292, Jammu has recorded the highest number of cases since July, when it was first reported this year.\nIt was followed by Kathua (12), Samba (11), Rajouri, Udhampur, Doda (six each), and Poonch and Kishtwar (one each), the officials said.\nThey said one case of dengue was reported from Kashmir.\nThe officials said 2,023 tests were conducted till yesterday and so far 336 people including 111 children and 84 women were tested positive for dengue, while 268 reports are still awaited.\nHowever, there was no fresh case of swine flu which claimed three lives in the Jammu region since July, the officials said.\nHea"
},
{
title : "Plethora of diseases threaten to mar festivities",
url : "http://www.thehindu.com/news/cities/Delhi/plethora-of-diseases-threaten-to-mar-festivities/article19880477.ece",
source : "Hindu: News",
date : "18.10.2017",
desc : "Doctors ask people to stay away from Diwali pollution, urge them to take precautionary measures"
},
{
title : "No side effects in Nilavembu: TN health minister",
url : "http://www.deccanchronicle.com/nation/current-affairs/181017/no-side-effects-in-nilavembu-tn-health-minister.html",
source : "",
date : "18.10.2017",
desc : "Chennai: Rubbishing the reports in a section of the media that Nilavembu kashayam causes infertility, state health minister Dr Vijayabaskar on Tuesday insisted that the herbal decoction has been tested scientifically and proved effective against several types of fevers, including Dengue and Chickungunya.\n"People should not believe in baseless rumours that Nilavembu kashayam will cause side effects. This herbal medicine has been tested well and used widely in many countries", the minister said, responding to reports in a section of the media that the use of this medicine could lead to infertility.\nElaborating on the good caused by the herbal medicine in the treatment of fevers, the minister said it had been approved for public use by Jayalalithaa during her tenure as Chief Minister when Chickungunya broke out.\n"We will continue to make elaborate arrangements to distribute Nilavembu kudineer to the public. Also, the government hospitals have been instructed to ensure proper hydration of ..."
},
{
title : "Dengue cases in Hyderabad on rise due to continuous rainfall",
url : "http://www.deccanchronicle.com/nation/current-affairs/171017/dengue-cases-in-hyderabad-on-rise-due-to-continuous-rainfall.html",
source : "",
date : "17.10.2017",
desc : "<p><strong>Hyderabad:<\/strong> Continuous rainfall over the past few days has sent dengue numbers soaring in Hyderabad, doctors said, on Tuesday.<\/p><p>"There are a lot of Chikungunya and dengue cases and continuous rain has given way to viral flu," said a doctor at a local hospital, Doctor Shankar.<\/p><p>He added that the stagnant water has led to mosquito breeding, thus, further aggravating the problem.<\/p><p>One of the patients at a hospital said many people have been complaining of health issues due to the weather change.<\/p><p>"My child is suffering from fever from the past one week, people are unable to use roads due to severe waterlogging and there is heavy traffic," said a resident.<\/p>"
},
{
title : "Bengaluru: First came the deluge, now comes the disease",
url : "http://www.deccanchronicle.com/lifestyle/health-and-wellbeing/171017/first-came-the-deluge-now-comes-the-disease.html",
source : "",
date : "17.10.2017",
desc : "With the rains showing no signs of letting up, there has been an outbreak of vector-borne and water-borne diseases across the city. There have been 4,990 cases of dengue and 116 cases of chikungunya since January in Bengaluru alone. Experts blame it on the lack of awareness among people and the general apathy of the BBMP when it comes to keeping the city clean. The problem needs to be dealt with on a war footing. Joyeeta Chakravorty and Chandrashekar G report.\nFirst the deluge and then the disease. Having received a record rainfall, the highest in 115 years this monsoon, which has left its roads and homes flooded and even washed away a few people , Bengaluru is now witnessing the inevitable outbreak of disease. With rain water refusing to run off in some localities with their blocked drains and large potholes, there is a bigger than usual influx of mosquitoes and a spike in vector-borne diseases like dengue and chikungunya. People are also coming down with gastroenteritis, typhoid and jaundice, leaving ..."
},
{
title : "Dengue claims two more lives",
url : "http://www.thehindu.com/news/cities/Delhi/dengue-claims-two-more-lives/article19873788.ece",
source : "Hindu: News",
date : "17.10.2017",
desc : "Two more persons, including a 26-year-old Manipuri woman, have succumbed to dengue in the Capital, even as the number of people affected by the vector-borne disease this season has risen to 5,220, as..."
},
{
title : "Vector-borne diseases spread tentacles",
url : "http://www.tribuneindia.com/news/punjab/vector-borne-diseases-spread-tentacles/483293.html",
source : "The Tribune",
date : "17.10.2017",
desc : "<p>Chandigarh, October 16\n<\/p><p>Dengue and chikungunya have started tightening their grip around Punjab with a large number of cases being reported from the state in the past two months.\n<\/p><p>According to the latest statistics compiled by the Department of Health and Family Welfare, so far more than 3,500 confirmed cases of dengue have been reported. Besides, around 9,000 suspected cases of dengue have also been reported in this season so far. — TNS <\/p>"
},
{
title : "Dengue snuffs out two more lives",
url : "http://www.tribuneindia.com/news/delhi/dengue-snuffs-out-two-more-lives/483238.html",
source : "The Tribune",
date : "17.10.2017",
desc : "Tribune News Service\nNew Delhi, October 16\nTwo more persons, including a 26 -year-old Manipuri woman, have succumbed to dengue in the city even as the number of people affected by the vector-borne disease this season has reached 5,220, according to a municipal report released today.\nThe mosquito-borne tropical disease had claimed its first victim in the city this year, when a 12-year-old boy died of dengue shock syndrome at Sir Ganga Ram Hospital (SGRH) on August 1.\nRhoda Daimai, who was living in Sarita Vihar, South Delhi, died on August 27 of septicaemia and other ensuing complications while 49-year-old Meena Devi, hailing from Bihar, died of dengue on September 2, the report said.\nCivic bodies said Daimai was a resident of a village in Manipur and had come to Delhi seeking treatment while Meena lived in Karawal Nagar in East Delhi. While Meena also died at SGRH, Rhoda succumbed at Holy Family Hospital.\nThe number of malaria and chikungunya cases recorded in the city till October 14 at 1,062 and 683, ..."
},
{
title : "33 new dengue cases",
url : "http://www.tribuneindia.com/news/ludhiana/33-new-dengue-cases/481972.html",
source : "The Tribune",
date : "14.10.2017",
desc : "<p>Tribune News Service\n<\/p><p>\n<\/p><p>Ludhiana, October 13\n<\/p><p>As many as 33 fresh dengue cases have surfaced from the city. The total count of confirmed dengue patients has now gone up to 183. The high-risk area from where the maximum cases are being reported is Mundian. Two new cases of chikungunya have also been confirmed.\n<\/p><p>District epidemiologist, Dr Ramesh, said people should be careful. They should not let water collect in and around their houses, he added.\n<\/p><p>“We are regularly educating people regarding symptoms and precautions of dengue. Stress is being laid in the high-risk areas. One can report a suspected case of dengue to nearest government dispensary/hospital or at the Civil Surgeon Office control room phone No. 0161-2444193,” he said. \n<\/p><p> “Test for dengue is being done free of cost at the Civil Hospital in the city,” he added. <\/p>"
},
{
title : "Delhi district courts lawyers will go on strike tomorrow",
url : "http://www.business-standard.com/article/current-affairs/delhi-district-courts-lawyers-will-go-on-strike-tomorrow-117101200359_1.html",
source : "Business Standard: News Now",
date : "12.10.2017",
desc : "The lawyers of all six district courts in the national capital will go on a day-long strike tomorrow to protest against alleged misconduct of some judges.\n\"The reasons for calling a complete strike are misconduct of judges with litigants and huge corruption in the judiciary. We have already given the names of erring judges to the High Court but no action has been taken so far,\" advocate Jaiveer Singh Chauhan, Secretary General of the coordination committee of Delhi bar associations, said.\nIn a unanimous resolution adopted by the Coordination Committee of all District Court Bar Associations here, it was alleged that some judges were repeatedly misbehaving with the lawyers by treating them as subordinates.\nThe strike is likely to paralyse work in all six district courts at Patiala House, Rohini, Saket, Tis Hazari, Dwarka and Karkardooma.\nYesterday, the lawyers at the Tis Hazari Court had also gone on a strike to protest against the alleged \"rude behaviour\" of a ..."
},
{
title : "Nuh residents to get free insecticide nets",
url : "http://www.tribuneindia.com/news/haryana/nuh-residents-to-get-free-insecticide-nets/480811.html",
source : "The Tribune",
date : "12.10.2017",
desc : "<p>Nuh residents to get free insecticide nets<\/p>\n\n<p>Chandigarh, October 11<\/p>\n\n<p>Health Minister Anil Vij said that 1.74 lakh insecticide nets would be given away free of cost to control vector-borne diseases in Nuh district. As many as 142 high-risk villages have been identified for this purpose.<\/p>\n\n<p>The minister said that insecticide nets had been received from the Central Government and soon they would be distributed among residents. He said that due to proximity to Delhi, cases of malaria were found to be more in Mewat area as compared to other areas of the state during recent years.<\/p>\n\n<p>Vij said that 72,000 RDT kits had also been sent to Nuh district for rapid testing of blood in case of diseases such as malaria, chikungunya, dengue and others. “The report of the test conducted on RDT kits can be obtained in 15-20 minutes. As per requirement, such kits have also been provided to Palwal and Yamunanagar districts,” he said.—TNS<\/p>"
},
{
title : "Vector-borne diseases keep Health Dept on toes",
url : "http://www.tribuneindia.com/news/chandigarh/vector-borne-diseases-keep-health-dept-on-toes/479936.html",
source : "The Tribune",
date : "10.10.2017",
desc : "Tribune News Service\nPatiala, October 9 \nWith the rise in the number of dengue and chikungunya cases, the possibility of an outbreak of these two diseases looms large over Patiala. \nAs many as 366 cases of dengue and 61 cases of chikungunya were reported in the district, which is now keeping the Patiala Health Department on its toes. While dengue cases have started coming in from July, chikungunya cases have been reported from August onwards. \nThough the Health Department has already deployed a rapid response team and a surveillance team in the city to treat patients, the increasing number has become a cause of concern for the authorities. Now, they are taking precautionary measures to ensure that the diseases do not spread in other areas. \nDistrict Epidemiologist Dr Gurmanjeet Kaur said, “Dengue and chikungunya tests are done free of cost at government hospitals. Patients get treatment free of cost.” \nShe said the department had already carried out fogging in areas and the affected persons were getting ..."
},
'' // Last item -- needed because previous item ends with a comma
]
</script>
I've made use of the m flag in several of the RegExps. I've assumed that various things can only appear at the start of a line, which is true in your example data but it's so brittle making that assumption.
This question already has answers here:
How do I consume the JSON POST data in an Express application
(7 answers)
Closed 5 years ago.
I am sending JSON data from my client side to my server side and then I am trying to extract the title values from the json. I have tried many different ways to parse the json and I am not able to figure out the proper way to do it. Can someone kindly suggest me what should I do?
snippet of my client side
if (response.status == 'ok') {
$.ajax({
type: 'POST',
url: '/home',
data: JSON.stringify(info),
success: function (data) {
},
error: function (data) {
console.log('error');
console.log(data)
}
});
}
Server side -
app.post("/home",function(req,res)
{
var name = req.body;
console.log("name",name);
});
JSON data at my server side -
{ '[{"title":"Queen\'s Speech outlines UK government\'s agenda at troubled time for May","pubDate":"2017-06-21 12:28:31","link":"http://www.cnn.com/2017/06/21/europe/queens-speech-theresa-may/index.html","guid":"http://www.cnn.com/2017/06/21/europe/queens-speech-theresa-may/index.html","author":"","thumbnail":"","description":"Britain\'s embattled Prime Minister Theresa May\'s attempt to lead a minority government starts in earnest Wednesday amid a backdrop of terror attacks and the fire at Grenfell Tower, one of the country\'s worst disasters for a generation.","content":"Britain\'s embattled Prime Minister Theresa May\'s attempt to lead a minority government starts in earnest Wednesday amid a backdrop of terror attacks and the fire at Grenfell Tower, one of the country\'s worst disasters for a generation.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170621115550-04-queen-opening-parliament-0621-super-169.jpg"},"categories":': [ 'http//cnnios-f.akamaihd.net/i/cnn/big/test/360/parliament_normal_day_vr_48770_,768x432_1500,960x540_2500,1280x720_3500,1920x1080_5904,.mp4.csmil/master.m3u8","guid":"cnn://360video=http://cnnios-f.akamaihd.net/i/cnn/big/test/360/parliament_normal_day_vr_48770_,768x432_1500,960x540_2500,1280x720_3500,1920x1080_5904,.mp4.csmil/master.m3u8","author":"","thumbnail":"","description":"","content":"","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170322122603-parliament-normal-day-full-360-super-169.jpg"},"categories":[]},{"title":"Brussels Central Station attack suspect identified","pubDate":"2017-06-21 10:35:42","link":"http://www.cnn.com/2017/06/21/europe/brussels-train-station-attack/index.html","guid":"http://www.cnn.com/2017/06/21/europe/brussels-train-station-attack/index.html","author":"","thumbnail":"","description":"Belgian authorities now know the identity of a man who was fatally shot at Brussels Central Station after a failed bombing, a spokeswoman for the Minister of Security and Home Affairs told CNN on Wednesday.","content":"Belgian authorities now know the identity of a man who was fatally shot at Brussels Central Station after a failed bombing, a spokeswoman for the Minister of Security and Home Affairs told CNN on Wednesday.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170620161931-09-brussels-train-station-incident-0620-super-169.jpg"},"categories":[]},{"title":"Duterte pledges to rebuild ISIS-infested Philippines city","pubDate":"2017-06-21 09:14:49","link":"http://www.cnn.com/2017/06/21/asia/philippines-isis-marawi-duterte/index.html","guid":"http://www.cnn.com/2017/06/21/asia/philippines-isis-marawi-duterte/index.html","author":"","thumbnail":"","description":"Philippines President Rodrigo Duterte begged forgiveness Tuesday for declaring martial law in Mindanao island and vowed to rebuild Marawi, the battle-scarred city at the heart of nearly four weeks of fighting between Philippines forces and ISIS-affiliated militants.","content":"Philippines President Rodrigo Duterte begged forgiveness Tuesday for declaring martial law in Mindanao island and vowed to rebuild Marawi, the battle-scarred city at the heart of nearly four weeks of fighting between Philippines forces and ISIS-affiliated militants.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170620204732-duterte-marawi-june-20-super-169.jpg"},"categories":[]},{"title":"Oscar legend Daniel Day-Lewis retiring from acting","pubDate":"2017-06-21 09:48:48","link":"http://www.cnn.com/2017/06/21/entertainment/daniel-day-lewis-retires-acting/index.html","guid":"http://www.cnn.com/2017/06/21/entertainment/daniel-day-lewis-retires-acting/index.html","author":"","thumbnail":"","description":"Actor Daniel Day-Lewis has officially announced his retirement.","content":"Actor Daniel Day-Lewis has officially announced his retirement.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170621163711-daniel-day-lewis-super-169.jpg"},"categories":[]},{"title":"India arrests 15 for celebrating Pakistan cricket victory","pubDate":"2017-06-21 10:43:38","link":"http://www.cnn.com/2017/06/21/asia/india-arrest-pakistan-cricket/index.html","guid":"http://www.cnn.com/2017/06/21/asia/india-arrest-pakistan-cricket/index.html","author":"","thumbnail":"","description":"Fifteen Indian men are facing lengthy jail sentences for allegedly cheering on the Pakistan cricket team.","content":"Fifteen Indian men are facing lengthy jail sentences for allegedly cheering on the Pakistan cricket team.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170619090748-pakistan-celebrate-super-169.jpg"},"categories":[]},{"title":"After four attacks, how will the UK fight terror?","pubDate":"2017-06-21 11:46:48","link":"http://www.cnn.com/videos/world/2017/06/21/uk-terror-attacks-police-government-response-jlm-orig.cnn","guid":"http://www.cnn.com/videos/world/2017/06/21/uk-terror-attacks-police-government-response-jlm-orig.cnn","author":"","thumbnail":"","description":"With the nation on high alert, British security services are hard at work to prevent future attacks.","content":"With the nation on high alert, British security services are hard at work to prevent future attacks.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170621101544-uk-terror-police1-super-169.jpg"},"categories":[]},{"title":"Chelsea Clinton: Bannon \'fat shamed\' Spicer","pubDate":"2017-06-21 06:21:55","link":"http://www.cnn.com/2017/06/20/politics/chelsea-clinton-fat-shaming-sean-spicer-steve-bannon/index.html","guid":"http://www.cnn.com/2017/06/20/politics/chelsea-clinton-fat-shaming-sean-spicer-steve-bannon/index.html","author":"","thumbnail":"","description":"The punchline, for lack of a better word, in a piece in The Atlantic on the much-maligned decay of the White House press is a text message, presumably joking, from White House adviser Steven Bannon to a reporter explaining why Sean Spicer has spent less and less time in front of cameras at the podium.","content":"The punchline, for lack of a better word, in a piece in The Atlantic on the much-maligned decay of the White House press is a text message, presumably joking, from White House adviser Steven Bannon to a reporter explaining why Sean Spicer has spent less and less time in front of cameras at the podium.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/161104201013-chelsea-clinton-oct-17-super-169.jpg"},"categories":[]},{"title":"House Russia probe digs into voter roll hacks","pubDate":"2017-06-21 08:04:20","link":"http://www.cnn.com/2017/06/21/politics/jeh-johnson-congress-hearing/index.html","guid":"http://www.cnn.com/2017/06/21/politics/jeh-johnson-congress-hearing/index.html","author":"","thumbnail":"","description":"House investigators will examine on Wednesday Russia\'s attempts to hack into state elections systems with former Department of Homeland Security Secretary Jeh Johnson before the House intelligence committee.","content":"House investigators will examine on Wednesday Russia\'s attempts to hack into state elections systems with former Department of Homeland Security Secretary Jeh Johnson before the House intelligence committee.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/151207100809-jeh-johnson-defense-one-00001404-super-169.jpg"},"categories":[]},{"title":"Trump: Death of US student held in N. Korea was \'disgrace\'","pubDate":"2017-06-20 18:41:36","link":"http://www.cnn.com/2017/06/20/politics/trump-otto-warmbier-north-korea/index.html","guid":"http://www.cnn.com/2017/06/20/politics/trump-otto-warmbier-north-korea/index.html","author":"","thumbnail":"","description":"President Donald Trump on Tuesday suggested that Otto Warmbier, the American who died days after his release from North Korea, would still be alive if he had been released sooner.","content":"President Donald Trump on Tuesday suggested that Otto Warmbier, the American who died days after his release from North Korea, would still be alive if he had been released sooner.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/170615120947-warmbier-coma-split-restricted-super-169.jpg"},"categories":[]},{"title":"Warmbier family declines autopsy","pubDate":"2017-06-21 11:33:35","link":"http://www.cnn.com/2017/06/20/health/otto-warmbier-autopsy/index.html","guid":"http://www.cnn.com/2017/06/20/health/otto-warmbier-autopsy/index.html","author":"","thumbnail":"","description":"The family of American college student Otto Warmbier objected to an autopsy, leaving the former North Korea detainee\'s official cause of death a mystery for the time being.","content":"The family of American college student Otto Warmbier objected to an autopsy, leaving the former North Korea detainee\'s official cause of death a mystery for the time being.","enclosure":{"link":"http://i2.cdn.turner.com/cnnnext/dam/assets/160122111735-01-otto-warmbier-super-169.jpg"},"categories":[]}]' ] }
JSON.parse?
app.post("/home",function(req,res){
var data = JSON.parse(req.body);
console.log("name",data.name);
});