Javascript String template parsing for keywords


I have a string template with few dynamic keywords like:

I am {{name}} from {{city}}

For a given input string I want to match it against the template and extract the name and city from the input in Javascript.
Eg. input I am Alex from Paris should give me name as Alex and city as Paris.

Is there some standard way of performing such operations in Javascript ?

Source: JavaSript – Stack Overflow

November 27, 2021
Category : News
Tags: javascript | regex | string

Leave a Reply

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

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.