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 7192829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:02:03+00:00 2026-05-28T20:02:03+00:00

In the example below I am trying to capture the text between the two

  • 0

In the example below I am trying to capture the text between the two asterixes.

var str="The *rain in SPAIN* stays mainly in the plain"; 
var patt1=/\*...\*/;
console.log(str.match(patt1));

I’m trying to follow the example here

http://www.regular-expressions.info/examples.html

\Q…\E Matches the characters between \Q and \E literally,
suppressing the meaning of special characters.

But I am having trouble following along

  • 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. Editorial Team
    Editorial Team
    2026-05-28T20:02:04+00:00Added an answer on May 28, 2026 at 8:02 pm

    Try

    var str="The *rain in SPAIN* stays mainly in the plain"; 
    var patt1=/\*.*\*/;
    console.log(str.match(patt1));
    

    The \* means the literal “*” character. Then the . means any character and * means any number of times, so .* means “any number of characters”.


    Optional bonus:

    The code above should work fine, but you’ll notice that it matches greedily. So with input abcd*efgh*ijkl*mnop, the output will be *efgh*ijkl*, whereas you might have preferred the non-greedy match *efgh*.

    To do this, use

    var patt1=/\*.*?\*/;
    

    The ? operator indicates non-greediness and ensures the least number of characters possible to get to the next \* are eaten, whereas without the ?, the most characters possible to get to the next \* are eaten.

    To learn more I recommend http://www.regular-expressions.info/repeat.html . In particular read the “laziness instead of greediness” part.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to capture two key presses in my VB.net application, for this example
In the example below I'm trying to access the parents sibling. Is there a
I'm trying to perform a group by action on an aliased column (example below)
Below I have a very simple example of what I'm trying to do. I
In my example below I'm using a dijit.form.DateTextBox : <input type=text name=startDate dojoType=dijit.form.DateTextBox constraints={datePattern:'MM/dd/yyyy'}
In the code example below, I'm trying to test the value of an enum
I am trying to capture the duration elapsed between touch start and end, and
In the example below, I'm trying to figure out how to hide the fieldset
I am trying to only pull out the number 88 in the example below:
I am trying to understand how Sequel works. The example below inherit from Sequel::Model

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.