3 ms·
I think this may be a counterexample to “Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
by Someone 4y ago
I think this may be a counterexample to
“Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.”
Something along the lines of
let r = Regex("\s*(?:(false)|true)\s*").ignoresCase()
will match “false” or “true”, ignoring leading and trailing whitespace and case, and one can test whether it matched “false” or “true” by checking whether the captured group is empty.
It also doesn’t produce a space-trimmed copy of the string.