19
1
Introduction
My car speedometer was hacked! Instead of showing me how fast i'm driving, it just shows: "Vroooom!" Please help me know how fast i'm going.
Challenge
Take a string as input, and check if it matches the regex /^[Vv]ro*m!$/m. In English that means any line of the string must start with a capital or lowercase v, then a lowercase r, then any amount (including zero) of the lowercase letter o, then the exact string m!. There may be other lines, but the Vroom string must be on it's own line.
If you find a match, then you must count the amount of o's in the Vroom string and output it. If you don't find a match however, you should output any default value that can't be outputted otherwise (like -1 or an empty string)
Reminders
- I/O is in any reasonable format
- Standard loopholes are banned
- Submission may be a full program or function
- Input is guaranteed to only have 1 Vroom string
Scoring
This is code-golf, so the shortest code in bytes wins. However, I will not mark any answer as accepted.
Test cases
Input
Vrom!
Output 1
Input
vrooooooom!
Output 7
Input
Hello, Vroom!
Output (none)
Input
Foo bar boo baz
Vrooom!
hi
Output 3
Input
Vrm!ooo
Output (none)
Input
PPCG puzzlers pie
Output (none)
Input
hallo
vROOOm!
Output (none)
Can't tell
Vrm!fromVram!– l4m2 – 2018-11-03T08:56:01.417