I need to write a regular expression that matches with 3 slightly different strings and extracts values out of them
Strings are as follows (excluding quotes)
1. "Beds: 3, Baths: 3"
2. "Beds: 3 - Sleeps 10, Baths: 3"
3. "Beds: 3 - 10, Baths: 3"
Values to extract like, for
1. 3, 0 , 3
2. 3, 10, 3
3. 3, 10, 3
I have written something like
$pattern = '/Beds: ([0-9]+).*-[ Sleeps]* ([0-9]+).* Baths: ([\.0-9]+)/';
It matches with string 2 and 3, but not with string 1.
Just extract the digits from non-digits.