I have a Given statement in my feature file
Given I have $100.25 in my bank account
The following step definition is not picking up the decimal fraction
@Given("I have \\$\\d+(\\.\\d+) in my bank account")
public void given_money_in_bank_Account(double money){
//This returns money as .25
}
I am sure my regex is correct here. How can I get 100.25 passed as argument?
You have a misplaced group. It should be I have \\$(\\d+\\.\\d+) in my bank account
.
But parsing floating point numbers with regex is not recommended. You have dozens of representation to represent a floating point number and the above regex only caters to a few.