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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:19:54+00:00 2026-05-16T02:19:54+00:00

I have the following possible string: ‘ ‘, or ‘4. ‘, or ‘*.4’ or

  • 0

I have the following possible string:
‘‘, or ‘4.‘, or ‘*.4’ or ‘4.35’
all the above format are valid, others are all invalid.
basically, if I don’t care the digit or word character, this is what I used in PHP for the validation:

        else if ( !ereg('^\*|.*\..*$',$bl_objver) )

Now, I would like to add some clientside validation, so I just translate it into javascript:

    var ver_reg = new RegExp("^\*|.*\..*$");
    if (ver_reg.test(obj_ver) == false)

but firebug always shows some error, like: “invalid quantifier |...*$” etc..

any suggestions?

  • 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-16T02:19:54+00:00Added an answer on May 16, 2026 at 2:19 am

    (I’m not convinced your expression is correct, but for the moment just going with what you have.)

    Using the RegExp object, you need to escape the slashes:

    var ver_reg = new RegExp("^\\*|.*\\..*$");
    

    Alternatively you can use regex literal notation:

    var ver_reg = /^\*|.*\..*$/;
    

    That answers your direct question, but…

    As for the expression, well, what you definitely want to correct is the start/end anchors each applying to one side of the alternation.

    i.e. you’re saying <this>|<that> where <this> is ^\* and <that> is .*\..*$

    What you want is ^(?:<this>|<that>)$ to ensure the start/end markers are not part of the alternatives (but using ?: since we’re not capturing the group).

    So /^(?:\*|.*\..*)$/ using the second example above – this fix would also need applying to the PHP version (which can use the same syntax).

    I’d also question your use of . instead of \w or [^.] or similar, but without knowing what you’re actually doing, I can’t say for sure what makes most sense.

    Hope this helps! 🙂

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

Sidebar

Related Questions

I have the following sql query for transforming data but is it possible to
Is it possible to merge elements using XSLT. If I have the following XML
Is it possible to have something like the following: class C { public Foo
I have some thread-related questions, assuming the following code. Please ignore the possible inefficiency
I have following string String str = replace :) :) with some other string;
I have following foreach-loop: using System.IO; //... if (Directory.Exists(path)) { foreach(string strFile in Directory.GetFiles(path,
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
If have following class public abstract class MyBaseClass : BaseClass { public override string
i am implementing dictionary in which key is a string keyword.suppose i have following
I have the following string sometextsometextSiteId-111-aaaaasometext If the string contains SiteId-111-aaaaa I would like

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.