2 ms·
I've said it before and I'll say it again, I'd like Python a lot more if it abandoned re and handled regex like perl did.
by autoexec 9mo ago
I've said it before and I'll say it again, I'd like Python a lot more if it abandoned re and handled regex like perl did.
- edflsafoiewq 9mo agoI've never used perl. What's the difference?
- autoexec 9mo agoIt doesn't need an import at all. It's just a normal part of the language's syntax and can be used just about anywhere: $foo =~ /regex/ $result = $foo =~ /regex/ if ($foo =~ /regex/) {whatever;} while (/regex/) {whatever;} The captures ($1, $2, etc.) are global and usable wherever you need them. In this particular case the default is that $ matches the end of a string without a newline but you can include it anytime you need to: $foo =~ /regex$/ # end of string without newline $foo =~ /regex$/m # end of string with newline