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

  • Home
  • SEARCH
  • 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 6057371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:28:52+00:00 2026-05-23T08:28:52+00:00

Well, I just don’t seem to understand certain things about RegExp . Can someone

  • 0

Well, I just don’t seem to understand certain things about RegExp.
Can someone please shed some light on me? Are there some implicit words in RegExp which result in a nonmatch? My assumption is that the substring “slt” contains some hidden top secret James Bond sign which makes the RegExp fail.

Demo to fiddle around:
working demo

//does not work
var funcArgString="c09__id slt ccc";
var myRegExp = new RegExp("([^ \s]*) ([^ \s]*) ([^ \s]*)","g");
alert(myRegExp.exec(funcArgString));

//works... why???
var funcArgString="c09__id abcdefg ccc";
var myRegExp = new RegExp("([^ \s]*) ([^ \s]*) ([^ \s]*)","g");
alert(myRegExp.exec(funcArgString));

//works as well
var funcArgString="c09__id slt ccc";
var myRegExp = new RegExp("(.*) (.*) (.*)","g");
alert(myRegExp.exec(funcArgString));
  • 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-23T08:28:53+00:00Added an answer on May 23, 2026 at 8:28 am

    If you you want to use a backslash \ in you regex, you have to use two \\ if you pass the expression as string:

    var myRegExp = new RegExp("([^\\s]*) ([^\\s]*) ([^\\s]*)","g");
    

    The backslash is the escape character in JavaScript strings and it will be evaluated as such. To insert a literal backslash, you have to escape it (hence the double backslash).

    Also note that you can omit the extra space in the character group, as it is already covered by \s.

    I assume JavaScript is discarding \s as invalid character sequence and takes s literally.

    This is the resulting expression of you only use one backlash:

    > new RegExp("([^\s]*) ([^\s]*) ([^\s]*)","g");
      /([^s]*) ([^s]*) ([^s]*)/g
    

    My assumption is that the slt contains some hidden top secret james bond sign which makes the regexp fail

    Yes, the villain is s in this case 😉 ([^s]*) matches every character but an s so the first string is not matched.

    Updated DEMO

    Alternatively, you can use a regex literal. As it is literal (and not in a string), we don’t have to escape the backlash:

    var funcArgString="c09__id slt ccc";
    var myRegExp = /([^\s]*) ([^\s]*) ([^\s]*)/g;
    alert(myRegExp.exec(funcArgString));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's well-known among teachers that some people can program and some can't. They just
Maybe I just don't know .NET well enough yet, but I have yet to
A Java version of this question was just answered, and, well, I don't know
I'm new to development on the iPhone. Just about every sample project (as well
Not that it matters strictly, and maybe I just don't yet fully understand how
Here's my ExtJs component. Everything works perfectly.... err well almost everything. I just don't
Well I know it's not evil just not as pretty in semantics as <strong>
Ok another WPF question, well I guess this is just general .NET. I have
There's something I just don't get regarding config files and dev or prod environments.
First, I understand the how of iteratees, well enough that I could probably write

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.