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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:07:32+00:00 2026-06-14T06:07:32+00:00

After a few tutorials I thought I had this, but nope — I am

  • 0

After a few tutorials I thought I had this, but nope —

I am trying to only match a string of letters, numbers, spaces, hyphens, periods, and underscores only and must begin with a letter in a jquery function

This is what I came up with after the tutorials but it only accepts letters:

/^[a-z][a-z0-9_ .-]*?/i

Please help!

++EDITED++

This is the code where I am trying to use this:

$('input[name=albumName]').keyfilter(/^[a-z][a-z0-9_ .-]*?/i);

The name that a user is entering will also be used in a URL so I want to limit their entry. I would want this to be allowed ( Texas AandM – 2012 ) but this not to be allowed ( 2012 – Texas A&M )

  • 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-06-14T06:07:33+00:00Added an answer on June 14, 2026 at 6:07 am

    Your regex looks ok to me. Perhaps there is a problem with the surrounding code rather than the regex? This is a Python example:

    s_re = re.compile('^[a-z][a-z0-9_.-]*',re.I) # case insensitive match
    
    In [12]: if s_re.match('A'): print 'match'
    match
    
    In [14]: if s_re.match('A.-'): print 'match'
    match
    
    In [15]: if s_re.match('1.-'): print 'match'
    
    In [16]: if s_re.match('1_.-'): print 'match'
    
    In [17]: if s_re.match('A_.-'): print 'match'
    match
    

    If you want to make sure you want at least one character after the first letter, you can replace the * with a +, or {2,} with at least 2 more characters, or {2,5} with between 2 and 5 characters.

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

Sidebar

Related Questions

This is probably such a simple question, but after reading a few tutorials and
I originally thought this was a WordPress issue - but realize after hours of
After few weeks break, I'm trying to expand and extend my knowlege of templates
Kinda of embarrassing to ask this question after few years working with Hibernate... I
After doing web development (php/js) for the last few years i thought it is
I am beginning in iPhone development and have followed a few tutorials, but please
I am trying to configure authentication using a few tutorials I have found on
I am aware that there were similar questions in past few years, but after
I'm trying to create simple Ajax call, but after clicking the link I get
I have read a few good articles about coding a socket server but thought

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.