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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:51:16+00:00 2026-06-04T16:51:16+00:00

I am currently constructing my matches using regex. I wanted to accept alphanumeric and

  • 0

I am currently constructing my matches using regex. I wanted to accept alphanumeric and special characters like period (.), comma (,) and dash (-) only. This is my code:

code nullable: false, blank: false, maxSize: 30, matches : /^[0-9a-zA-Z,.-]+?[0-9a-zA-Z ]+?[0-9a-zA-Z,.-]*?$/

This code works fine, but every time I entered a combination of a single letter and one of the specified special characters, an error message is thrown.

Example:

1) A. (an error is thrown)
2) A- (an error is thrown)
3) A, (an error is thrown)

The above example should be a valid input. How will I trim down my regex to allow the given examples?

  • 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-04T16:51:18+00:00Added an answer on June 4, 2026 at 4:51 pm

    A. is matched by [0-9a-zA-Z,.-]+? but the middle part [0-9a-zA-Z ]+? does’t match anything.

    To just match alphanumerics and period, comma and dash, /^[0-9a-zA-Z,.-]+$/ would be sufficient.

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

Sidebar

Related Questions

I'm currently constructing a project with a plugin structure. I'm using CMake to compile
I'm working on constructing a table using only divs. I began creating the table
I'm currently constructing loggers (with configgy) like this: class MyClass { private val log
Currently I have a class that looks like this: public class MyClass : IMyClass
Currently developing an application using the newest version of symfony, obtained through PEAR. This
I am currently constructing an OWL ontology, which - until very recently classified rapidly
i'm currently constructing some kind of mini-framework for a project, and come up with
Currently, I am constructing an XML document in PHP that will yield the following:
I am currently constructing a Carputer front end and one function that it needs
I'm currently constructing a database for users. the issue I am stuck with lies

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.