If you have a sentence like Hello “Good Morning!” and you want to extract the part inside the quotations you can use this solution.
You can match the sentence with regex /”(.*?)”/g. This regular expression finds the quotes and extracts the words inside the quotes.
console.log("Hello, \"Good Morning!\"".match(/"(.*?)"/g)); ["Good Morning!"]
Regex match returns an array.
Leave a Reply