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 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

I just don't understand and can't find much info about wchar end. If it
It's well-known among teachers that some people can program and some can't. They just
Well i was just wondering how i can run like two while loops at
Maybe I just don't know .NET well enough yet, but I have yet to
I haven't been able to find this anywhere (or I just don't understand it).
I am looking at a sample Rails application and see some strange things. Well
Here's my ExtJs component. Everything works perfectly.... err well almost everything. I just don't
I use AVAudioPlayer to play music file. It just works well when playing via
I just finished this script it works well, but I am struggling to pass
Well, just to keep it simple: I have a webform. On it 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.