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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:49:51+00:00 2026-06-13T13:49:51+00:00

I would like to validate residence address in the JavaScript using regex, but I

  • 0

I would like to validate residence address in the JavaScript using regex, but I dont know much about the regex, what I have tried is to build my own regex (/^[a-zA-Z\s](\d)?$/) but it doesn’t seem to work properly.

What I want to achieve is to allow letters, spaces and at least one digit (thats required) and also there should be a possibility to insert the slash / but it shouldnt be required.

Could anyone help me with that?

  • 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-13T13:49:52+00:00Added an answer on June 13, 2026 at 1:49 pm

    I’ll get you started, but you’ll find yourself becoming more specific as you get accustomed to regular expressions. First, let’s examine your regex:

    /^[a-zA-Z\s](\d)?$/
    

    The essential thing to note here is that this regex will only match, at most, a two-character string! The character class, [ ... ], matches a single character: in your case, letters and whitespace. You need to combine this with what’s called a quantifier, e.g. * meaning “zero or more”, + meaning “one or more”, and ? meaning “zero or one”. You’ve used a quantifier elsewhere, (\d)?, where you’re saying “zero or one” digit character. But what you really want looks more like this:

    /^[a-zA-Z\s\d\/]+$/
    

    Here, we’re saying “one or more” letters, whitespace, digits, or slashes (note that the forward slash must be escaped using a backslash).

    Finally, you say want to require “at least one” digit. This can be achieved with a more advanced construct in regular expressions, called “lookaround assertions.” You want this:

    /^(?=.*\d)[a-zA-Z\s\d\/]+$/
    

    That, in particular, is a positive lookahead assertion, which you can research yourself. An alternate way of doing this, without lookahead assertions, would be:

    /^[a-zA-Z\s\d\/]*\d[a-zA-Z\s\d\/]*$/
    

    This is obviously more complicated, but when you’re able to understand this, you know you’re well on your way to understanding regular expressions. Good luck!

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

Sidebar

Related Questions

I would like to know how can we validate the Credit Card. We have
I would like to know how one could validate a password with regex. I
I have the following regex. ^((?!example).)*$#Subdomain is reserved (example). I would like to validate
I would like to validate an email using the RegexValidator, e.g. [RegexValidator(@^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$)] Which works
I'm using jQuery Validate and would like to re-validate a group of fields whenever
I would like to create a regex to validate customer names. This would be
I have a simple form that I would like to validate on form submission.
I have a DateTime property in my model and I would like to validate
I have a string that I would like to validate a certain pattern for:
I would like to know, how can we validate the data, we can not

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.