JS:'bat bet bit'.match(/b.t/g)Py: re.findall(r'b.t','bat bet bit')
Output
["bat", "bet", "bit"]
Note The dot does NOT match newline (\n) by default. Use the s (dotall) flag to make dot match newline as well. A common beginner mistake is using . when you mean a literal period -- escape it as \. instead.
Frequently asked questions
How does JavaScript handle any match?
This task is covered in 2 stacks on this page: JavaScript, Regular Expressions. The "includes(), some(), every()" snippet in JavaScript uses `arr.includes(value)`.
Which code does the JavaScript example use?
The "includes(), some(), every()" snippet uses `arr.includes(value)`, from the Arrays section of the JavaScript cheat sheet.
Which stacks cover "any match" on this page?
JavaScript, Regular Expressions. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "includes(), some(), every()": includes() uses strict equality (===) and works with NaN. some() short-circuits on the first true; every() short-circuits on the first false.