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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:44:24+00:00 2026-05-30T07:44:24+00:00

im pretty new in grails.. im having a little problem right now on validation

  • 0

im pretty new in grails.. im having a little problem right now on validation using matches. What I wanted to happen is that a field can accept combination of alphanumeric and special characters, letters only and numbers only, and if the user inputs special characters only, the system should prompt the user an error.
i used matches constraints to validate the data, and im having a hard time how could i set the regex where the field will not accept an input with special characters only.
please help me.. thanks a lot for sharing your knowledge.

  • 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-30T07:44:25+00:00Added an answer on May 30, 2026 at 7:44 am

    I think I understand your problem, but correct me if I’m wrong. The input is valid as long as there is at least 1 letter or number, right? In other words, if there isn’t a letter or number (only special characters), then the input is invalid?

    See if this works:

    /^.*[A-Za-z0-9].*$/
    

    Here is my little groovy test:

    import java.util.regex.Matcher
    import java.util.regex.Pattern
    
    def pattern = ~/^.*[A-Za-z0-9].*$/
    
    assert pattern.matcher("abc").matches()
    assert pattern.matcher("ABC").matches()
    assert pattern.matcher("abc123").matches()
    assert pattern.matcher("123").matches()
    assert pattern.matcher("abc!").matches()
    assert pattern.matcher("!abc").matches()
    assert pattern.matcher("1!bc").matches()
    assert pattern.matcher("!.~").matches() == false
    

    Explained:

    /             regex start
    ^             start of string
    .*            any character (0 or more times)
    [A-Za-z0-9]   at least 1 letter or number
    .*            any character (0 or more times)
    $             end of string
    /             regex end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new on grails, I'm having a problem in matches validation using regex.
Im really having a hard time in matches constraints in grails, im pretty new
Am pretty new to ROR. Need help in Rails form validation. Am using rails
Pretty new to jquery and having a bit of a problem with a function
Im pretty new to coding, heres my problem. Results->Text = G55 > Y +
I'm pretty new to c# and I'm trying to make a function that checks
I am pretty new to Java, so I may be using incorrect terminology. I
I am pretty new to image capturing using java. Just started working in java.
Pretty new to sqlite (and sql). Trying to modify one table using another. create
still pretty new to android I have to clone an iphone application. Im having

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.