As you can see we simply add the backslash to the end of each line to tell the interpreter it’s part of the same long string.
var textFromChris = "me: we lunchin? Sent at 11:34 AM on Friday me: sure Sent at 11:58 AM on Friday chris: T=12.30 Sent at 12:07 PM on Friday"; var timeRegex = /T=([0-9.]+)/gm; timeRegex.compile(timeRegex); console.dir(timeRegex.exec(textFromChris));
Common error message: SyntaxError: unterminated string literal
Compatibility: Testing revealed that it works in all major browsers, including IE 6.
Obviously there are other ways we could achieve the same result. We could simply split the string up like this then it doesn’t matter that they are declared on separate lines.
var textFromChris = "me: we lunchin?" + "Sent at 11:34 AM on Friday" + "me: sure" + "Sent at 11:58 AM on Friday" + "chris: T=12.30" + "Sent at 12:07 PM on Friday"; var timeRegex = /T=([0-9.]+)/gm; timeRegex.compile(timeRegex); console.dir(timeRegex.exec(textFromChris));
Using Redis with Node.js
By Ivaylo Gerchev,
Need fast data interactions in your Node app? Learn how Redis speeds caching, message brokering, sessions, analytics, streaming and more.
By Rui Sousa,
You can now extend the Notion app with the new Notion API. Learn how to create an interface that connects Notion to an external database.
Build a Website with React and Tailwind CSS
By Shahed Nasser,
React and Tailwind CSS: a beautiful relationship! Learn how Tailwind frees you from writing CSS so you can focus on your React components.
Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.