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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:39:34+00:00 2026-06-10T12:39:34+00:00

I have a simple requirement. We use the hibernate validation engine to figure out

  • 0

I have a simple requirement. We use the hibernate validation engine to figure out if a constraint is true or false.

True should be a text if all the words starts with an uppercase character.
There are some difficulties:

Words could also start like this

8-Test
or even
8Test
or even
(Test)
or even
-Test
or anything comparable

Also usually they are comma separated (or a different separator):

Test, Test, Test

Remember I only want to make sure that words in the String starts uppercase. When you see my tries, probably I am overcomplicating things.

Here are some samples:
Expected to match all (true):

- Hydroxyisohexyl 3-Cyclohexene Carboxaldehyde, Benzyl
- Test, Test, Test
- CI 15510, Methylchloroisothiazolinone, Disodium EDTA
- N/A
- NA

Expected to not match all (false):

- hydroxyisohexyl 3-Cyclohexene Carboxaldehyde, Benzyl
- Test, test, Test
- CI 15510, Methylchloroisothiazolinone, Disodium eDTA
- na
- n/a

My tries were going into this directions:


final String oldregex = "([\\W]*\\b[A-Z\\d]\\w+\\b[\\W]*)+";
final String regex = "([A-Z][\\d\\w]+( [A-Z][-\\d\\w]+)*, )*[A-Z][-\\d\\w]+( [A-Z][-\\d\\w]+)*\\.";'

actually with “oldregex” option I ran into an infinitive calculation for some texts
Use this to test regex: http://gskinner.com/RegExr/ (without double backslashes of course)

Thanks for helping!!!

  • 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-10T12:39:35+00:00Added an answer on June 10, 2026 at 12:39 pm

    Regex

    See it in action:

    ^(?:[^A-Za-z]*[A-Z][^\s,]*)*[^A-Za-z]*$
    

    Explanation

    ^                # start of the string
    (?:              # this group matches a "word", don't capture the group
      [^A-Za-z]*     # skip any non-alphabet characters at start of the word
      [A-Z]          # force an uppercase letter as a first letter
      [^\s,]*        # match anything but word separators (\s and ,) after 1th letter
    )*               # the whole line consists of such "words"
    [^A-Za-z]*       # skip any non-alphabet characters at the end of the string
    $                # end of the string
    

    Note: You can modify the regex if your word separator characters different then whitespace and comma. (For example, change [^\s,] to [^,:-] or whatever you use)

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

Sidebar

Related Questions

I have what should be a fairly simple requirement. I want to use LINQ
We have a simple requirement to use https for certain specific pages in a
I have a simple requirement, i need a map of type . however i
I have a simple requirement as mentioned below: A ListView or any control displays
I am using django 1.4 and Python 2.7. I just have a simple requirement
I have an ASP ListView, and have a very simple requirement to display numbers
I have a requirement to create a simple windows forms application that allows an
I have a requirement which sounds like kind of simple but hard to implement
I have a fairly simple requirement for a query API which I need to
I have a simple requirement, but I seem to be struggling. I have created

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.