• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Why Reg Expression is not being matched our found

I have a couple strings such as this:
999 NO ACCT NUM NET PAY ARR
9830-1800

And I have a regular expression to do a String.Match("\\p{Lower}\\p{Upper}")

However, I seem to be not matching this string: 999 NO ACCT NUM NET PAY ARR

Thoughts?


0
Corey_819
Asked:
Corey_819
  • 5
  • 3
1 Solution
 
CEHJCommented:
It's quite far off matching

[\\p{Alnum} ]+

would need to be your pattern
0
 
Corey_819Author Commented:
Oh Dugh, I am a gobber. I didnot even think about the 3 9's Let me change. :)
0
 
CEHJCommented:
If you do that you can change Alnum to Alpha
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Corey_819Author Commented:
I am sorry CEHJ and I really appreciate the help and everthing works but why is it working this way:

97200100
98300100
999 NO ACCT NUM NET PAY ARR
OH    CO TAX ACT NOT ENTERED

These four strings are all passing the regExp match. I want these two 999 NO ACCT NUM NET PAY ARR , OH    CO TAX ACT NOT ENTERED, but not string with all numbers. Thoughts?


0
 
CEHJCommented:
You can more easily do that by:

if (s.indexOf(' ') > -1 && s.matches("[\\p{Alnum} ]+"))
0
 
CEHJCommented:
If you must retain a regex, the following would work

(\\w+\\s+\\w+){1,}
0
 
Corey_819Author Commented:
Ah Ha excellent idea. Thanks you have been great help :)
0
 
CEHJCommented:
:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now