11 ms·
For "6. A man, a plan", I thought it was impossible to match palindromes with regex, am I wrong?
by ZirconCode 13y ago
For "6. A man, a plan", I thought it was impossible to match palindromes with regex, am I wrong?
- quarterto 13y agoIt gives you hints below the score, for 6 it's: You're allowed to cheat a little, since this one is technically impossible. No idea how you cheat... EDIT, SPOILERS: I get 170 with ^(.?)(.)(.).?\3\2\1$
- mryingster 13y ago176 with ^(.)(.).*\2\1$
- deleted 13y ago[deleted]
- hyp0 13y ago^(.)[^p].*\1$ # 177, "cheat a little"
- deleted 13y ago[deleted]
- Yen 13y agoYou're pretty much correct. True regular expressions don't have the expressive power to decide whether arbitrary-length strings are or aren't palindromes. That said, 'regular expressions', as used in most programming languages, have extensions that extend the expressive power. One such extension is the matched group & backreference, used in other commentor's answers. From a theoretic stance, these aren't really 'regular expressions', but that's what we call them in practice.