user489041
user489041

Reputation: 28294

Regular Expression Can't Match

I have the following string:

8 0 0 . Item s Payable in Connection w ith Loan

I am trying to match it using the following regular expression:

^8\\s*0\\s*0\\.

What I believe this regular expression is saying is:

  1. 8 has to be at the beginning of the string
  2. There can be any amount of spaces between 8 and a 0
  3. There can be any amount of spaces between the first 0 and the second 0
  4. The last 0 must be followed by a period .

However in my application, this does match my string. Can any one rpvodie assistance on why it might not be matching. I am using Java.

Upvotes: 1

Views: 91

Answers (1)

there's a space between you last 0 and your period. your regular expression doesn't allow for that. that's why it's failing.

try

 "^8\\s*0\\s*0\\s*\\."

Upvotes: 5

Related Questions