Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:47:11+00:00 2026-05-10T21:47:11+00:00

In javascript, I’ve got a block of HTML like this: <h2>{title}</h2> <p><a href={url}>{content}</a></p> And

  • 0

In javascript, I’ve got a block of HTML like this:

<h2>{title}</h2> <p><a href='{url}'>{content}</a></p> 

And I’m trying use regex ‘match’ to spit out an array of all the {item}’s. So my output should look like:

['title', 'url', 'content'] 

I’ve gotten as far as:

var pattern = new RegExp('\{[a-zA-Z]+\}+'); var match = pattern.exec('{Sample} bob {text}'); 

But it’s only returning the first tag.

This is just beyond my regex skills. Can anyone help?

Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:47:12+00:00Added an answer on May 10, 2026 at 9:47 pm

    You need to create a pattern with the global flag:

    var pattern = new RegExp('\{[a-zA-Z]+\}', 'g'); 

    or:

    var pattern = /\{[a-zA-Z]+\}/g; 

    Then you can call the match() method on your string to get a list of matches:

    var matches = '{Sample} bob {text}'.match(pattern); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

JavaScript: var docHeadText = document.head.innerHTML; var patt =/\/*:.+?:*\//g; patt.compile(patt); docHeadText.match(patt); HTML: <head> <script type=text/javascript>
Javascript functions can be declared on a objects prototype like this: <object name>.prototype.<variable name>=function(){
I am trying to render a haml file in a javascript response like so:
Javascript regex and replace : Input : [url]testing data[/url] Replace by : <b> Result
JavaScript is purported to have first-class functions, so this seems like the following ought
Javascript function does not work when function loadcontents(obj) { var params = $(obj).attr('href').split('?'); $.getJSON(IVIDPLAY_BASE_DIR+'content/load2.php?'+params[1],
Javascript loop continue,or break to display? This is my code use for show or
JavaScript application often use one of the following methods: They use empty HTML elements
JavaScript is not my strong point, but then I'm not sure I'm hitting this
Javascript run at page opening or later by user action like clicking a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.