Skip to content

Extract quoted string from a sentence in JavaScript

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.

See also  Remove Primary Key constraint from a table column in MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.