4 ms·
That's not that wrong though. What does it do for queries like "all male English names" or "comfortable temperature range"?
by iforgotpassword 4y ago
That's not that wrong though.
What does it do for queries like "all male English names" or "comfortable temperature range"?
- memorable 4y agoFor "comfortable temperature range", it generates: (\d+\.?\d*)\s?-\s?(\d+\.?\d*) And for "all male English names", it generates: [A-Z][a-z]+ The first one might be good, but the latter seems rather unsophisticated.
- diarrhea 4y agoAll male English names is just a list. It doesn’t follow a grammar. Its regex would be akin to (John|Jane|Alice|Bob) and so on. It’s not a case for regex. In fact, I’ve found success in replacing regex with regular string operators (length, contains substring, doesn’t contain substring, starts with a capital letter, …) of the language at hand, then do final regex passes for whatever is left at the end. It’s infinitely more readable and debuggable. I’ve grown to avoid regex when possible.