Ich habe 2 Strings:Ruby-Regex passender String mit Zahlenbereich vorangestellt
I have 4 cars in my house
I have 14 cars in my house
Wie verwenden wir Rubin (1.9.3) Regex nur 1 bis 10 Auto überprüfen abgestimmt sind?
Ex:
I have 1 car in my house # => match
I have 4 cars in my house # => match
I have 10 cars in my house # => match
I have 14 cars in my house # => should not match
I have 100 cars in my house # => should not match
Auch, wie passen wir (das heißt 2 Autos) gegen alle Saiten? Wenn die Zielzeichenfolge "22 Autos" enthält, sollte sie nicht übereinstimmen.
Ex:
some other string before 2 cars some other string after # => match
some other string before 22 cars some other string after # => should not match
Was ist mit '/ Ich habe (1 Auto | [2-9] Autos | 10 Autos) in meinem Haus /'? – Howard
Sollten Ihre Autos nicht in Ihrer Garage sein? : D Howard gibt die richtige Antwort. Ich habe zuerst die Singularform verpasst. – alfa