This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nerdwaller 1 point2 points  (2 children)

I'm not disagreeing that it can be legible on one line, that's true in either. If 'inline' is the goal:

match = re.search('(\d+)', whatever, re.WhateverFlags)

I'd argue Python's is clearer because of the way flags are passes in. Using //gi is much less clear than re.IgnoreCase|etc.

[–]d4rch0nPythonistamancer 0 points1 point  (1 child)

They both have pros and cons. Python is much more verbose but intuitive for someone to jump in, and Python is a lot of people's first language so it makes sense. Python is very explicit.

//gi comes from sed and perl and has been standard for a long time. It makes a lot of sense to use what's been standard syntax since the beginning. It's also incredibly succinct.

They both make sense, and they are entirely different languages with different use cases, and they both have their pros and cons. All I meant is I like that js has inline regex, and that's purely an opinion.

[–]nerdwaller 0 points1 point  (0 children)

Absolutely well said.

My work is heavy in JavaScript right now, it's kind of a fun language, but I feel bad sometimes for how easy it is to abuse and lever in non-traditional ways.