16

This question has turned into a rollback war which I did not expect. I kept doing rollback to remove tag and the other user kept adding it.

  1. I'm 99% sure that I'm doing the right thing, see below for detailed explanation.
  2. From Put an end to rollback wars, a "rollback war" auto-flag should have been generated for moderator attention. If I understand it correctly, a custom flag isn't necessary, right?
  3. I'm sure the other editor and I both believe we are doing the right thing, but the rollback war isn't helping. I left a comment to further explain what I'm doing since the second rollback, but it seems that the comments are not helping, either.

My main question is, how to stop this rollback war?


There are quite a few questions in about pattern matching which are tagged with in the first place, and people kindly answered these questions with a regex solution. However, in most cases, the OP found out that these regexes don't solve their problems. That is because

Lua pattern isn't regex!

Programming in Lua explains why Lua doesn't have a native regex support like many other languages. Plus, people that like to find a more powerful pattern matching often choose LPeg, a library based on Parsing Expression Grammars, written by Roberto Ierusalimschy, one of Lua's authors.

As a simple example, you might expect (ab)+ to match one or more repetitions of ab. However, in Lua pattern matching, + applies to one character only.

There are questions that could be tagged with both and :

  • Questions that discuss the difference between Lua pattern and regex.
  • Questions that use a third party regex library.

However, in most cases, it turned out that the OP doesn't know Lua pattern isn't regex, and tagged the question with the wrong tag.

7
  • 30
    "How to stop this rollback war?" Easy: once another user rollbacks your edit twice (the first one could be by error), stop editing. Leave a comment, flag a moderator, bring it to meta or whatever, but continuing the edit war is pointless.
    – Oriol
    Commented Feb 6, 2016 at 4:50
  • 37
    150+K rep points total - that is really rare rollback war. Getting popcorn and finding good seat. :) Commented Feb 6, 2016 at 7:11
  • 5
    Your link says "Lua does not use POSIX regular expressions (regexp) for pattern matching.". Well, neither does Perl, .NET, Java, JavaScript, etc. Note the POSIX. I'd say if it can match a Chomsky Type 3 language then you can safely tag that with [regex]. (I don't know if Lua pattern matching counts as such). Commented Feb 6, 2016 at 13:19
  • 5
    The question in my mind is - if you use a POSIX RE, does LUA do what you expect with it? This is the rationale by which I allow pcre to also be tagged regex, because pcre is a superset of regular expressions. (And more widely available). But on the general point - it takes two to tango. Stop playing, and flag it for a mod.
    – Sobrique
    Commented Feb 6, 2016 at 19:27
  • meta.stackexchange.com/a/222644/302327 for criteria as to when the rollback war tag gets applied
    – MoralCode
    Commented Feb 7, 2016 at 1:37
  • 3
    The question probably should be renamed to reflect actual discussion as "rollback war" topic is completely abandoned here... (which good thing - there is really nothing new to add about dealing with rollback/edit wars). Commented Feb 7, 2016 at 7:06
  • 2
    c'mon man! This sounds like 2 children not getting along in a sandbox and running to tell mom. The way to stop it is to be a little humble once in a while and walk away. To bring this trivial episode about one tag to this point is childish
    – charlietfl
    Commented Feb 8, 2016 at 5:49

3 Answers 3

34

In computer science, "regular expression" has a very specific meaning. It's about functionality, about expressiveness, not about syntax, and even in CS theory there is no universal syntax. It's about what languages can be described by those expressions: regular expressions describe regular languages.

Admittedly, many implementations of regular expressions provide extensions that allow describing more than just regular languages. Nonetheless, those engines can be used to describe any regular language as well, and commonly are used for that. It might be fair, but would be highly impractical to not apply the regex tag to them.

If Lua patterns can describe all regular languages, they are regular expressions, even if they use a radically different syntax, and the tag should be appropriate for them.

If Lua patterns cannot describe all regular languages, they are not regular expressions, even if they have things in common with Perl/Unix/POSIX/... regular expressions, and the tag should not be appropriate for them.

The impression I get is that Lua patterns cannot describe all regular languages, meaning they are not regular expressions, and meaning the tag should not be used for them. For instance, quoting Programming in Lua:

Unlike some other systems, in Lua a modifier can only be applied to a character class; there is no way to group patterns under a modifier. For instance, there is no pattern that matches an optional word (unless the word has only one letter).

This is a fairly direct application of two of the core building blocks of regular expressions.

  • There must be a regular expression that only matches the empty string.
  • For any regular expression R1 and R2, there must be a regular expression that matches if and only if R1 and/or R2 matches.

If there's no way to express that in a Lua pattern, then Lua patterns are not regular expressions.

8
  • 7
    Well-reasoned. Might make a good addition to either wiki... Commented Feb 7, 2016 at 12:41
  • 3
    +1, I think you've hit the core of the issue. I don't care what the syntax looks like (because you can always translate from one syntax to another) or what extra non-regular matching features it might have, but if something can't match a regular language, then it's not a regex. Commented Feb 7, 2016 at 13:27
  • 1
    Well, by this argument, C++ can express all regular languages, so regex would be appropriate? I think not. Commented Feb 9, 2016 at 2:24
  • 1
    @Yakk Er... what? No, C++ cannot express all regular languages. C++ cannot express any language. C++ expresses programs. Some of those programs may then in turn detect languages, but that's entirely different. The impression that I get is that you don't know what a regular language is, and didn't follow the link. If that impression is correct, please do follow the link.
    – user743382
    Commented Feb 9, 2016 at 6:36
  • @hvd Programs can accept/reject strings. A program can be said to describe the language of strings it accepts. C++ is Turing complete, so the languages it can describe (via accept/reject) include all regular languages. CS theory 101, no? -- basically, you stated that "if a language is powerful enough to express/accept every particular regular language, regex applies": but almost every programming language passes that bar. I'd argue that syntax and style of the language is more important than its ability to recognize regular languages. Commented Feb 9, 2016 at 6:58
  • @Yakk That isn't what I wrote. Even if you restrict C++ to the programs that only accept/reject strings (I'm not sure this is fair), and treat those programs as the languages that are accepted (nor this), what you get isn't regular languages. What you get is a vast superset of the regular languages.
    – user743382
    Commented Feb 9, 2016 at 7:51
  • @hvd like perl regular expressions! (Well, moreso). My point is treating regex as a formal CS category of programming languages that match regular languages isn't reasonable in practice: many regex flavors are able to at least match context free, if not more. It is the shared conciets of the regex languages out there that matter: and by that metric, lua patterns are far closer to being regex. The inability for * and + to match groups nonwithstanding. Commented Feb 9, 2016 at 13:40
  • 1
    @Yakk Already covered that in my answer. "Admittedly, many implementations of regular expressions provide extensions that allow describing more than just regular languages. Nonetheless, those engines can be used to describe any regular language as well, and commonly are used for that." C++ definitely fails on that last part. It isn't commonly used merely to recognise a regular language.
    – user743382
    Commented Feb 9, 2016 at 13:52
6

There seem to be two questions here, one explicit and another implicit.

Explicit one first:

how to stop this rollback war?

It takes two to have a war. Wars are not useful; they only destroy. If you want to stop the war, don't participate. If you feel that the automated flagging system is not producing desired results, then go ahead and submit a flag. At least then you'll be able to see the status of the flag, i.e. whether a moderator has considered it or not and if so, what the disposition was.


Now, what about the implied question as to whether posts should also be permitted to have the tag. While Wikipedia is not definitive, I find it often has very good starting points for understanding terminology. And here too, I feel that's the case:

In theoretical computer science and formal language theory, a regular expression (sometimes called a rational expression) is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace"-like operations.

Any system of expressions that allows for pattern matching would be considered a "regular expression". I agree with Wiktor's answer, and I encourage you to take a look at the Meta Q&A commenter Lucas refers us to, as it provides a clear and useful comparison to the analogous situation for SQL questions.

Indeed, the guidance for the tag clearly states:

Always indicate which platform you need or want to use (programming language, tool, occasionally even version information). Keep in mind that regex dialects are different; the lowest common denominator will usually be quite different from what is possible and recommended for a tool with a modern, souped-up regex engine.

In other words, the is not reserved for any one, or even some specific class of regular expression languages. Rather, it's a catch-all for regular expressions in general. That would include such systems even if entirely different from the syntax and/or features found in platform-based regex, such as POSIX, Java, .NET, etc. That would include regular expressions as used in the Lua language, i.e. .


Now, given all that, one might debate the usefulness of the tag at all. It's necessarily broad and will nearly always require qualification with some more specific tag to precisely describe the post. But I don't see how one can argue it doesn't apply to a post using some specific flavor of regex. If anything, you might focus your efforts on revising the wiki for the tag, as it misleadingly states that pattern-matching in Lua is not a type of regular expressions (though I do see that you were complicit in this misattribution in the tag wiki…hopefully you now can see how Lua patterns are just as much "regular expressions" as any other pattern-matching syntax).

5
  • 11
    "it takes two to have a war": my thoughts exactly Commented Feb 6, 2016 at 19:12
  • @Andras Deak I do and do not feel strongly both ways about "it takes two to have a war". ;-)
    – chux
    Commented Feb 6, 2016 at 19:34
  • 1
    @chux no you yes you do! Commented Feb 6, 2016 at 19:50
  • 3
    About the usefulness of [regex], there are two kinds of people here: those who like pattern matching, and those who despise it. By using the tag, you attract the attention of the former ones, most of whom (I hope) already know the deal about regex flavors, and can adapt to them. Oh, and I downvote any [regex] question on sight which doesn't include a second tag or otherwise states the flavor, so yes it's a broad and non-standalone tag, but it gets you the right people to see your question. Commented Feb 7, 2016 at 0:49
  • 1
    First part is right, but second part is wrong. I therefore award you zero points.
    – user1228
    Commented Feb 8, 2016 at 15:21
3

To answer the main question, I'm sorry for participating in this edit war.


As for whether Lua pattern matching is a type of regex, I still say no.

The Python module for regex is called re, the Ruby library is called Regexp, in JavaScript/Java/C++/.NET, in sed/AWK/grep, in other languages/tools, you call it a regular expression.

Does the Lua community call its native pattern matching regular expression? In the reference manual, in lua-users, in whatever Lua community, people would tell you that Lua pattern matching isn't regex.

The pattern matching in Lua is so different. Here are a few examples:

  • It uses % to escape, not \, e.g, %d for digits and %s for whitespace.
  • There's no alternation operator and | is not a magic character.
  • The modifiers *, +, and ? applies to one character only.

  • The modifier {m,n} is not supported.

  • The non-greedy version of * is not *?, it's -.

I'd say Lua pattern matching isn't a flavor of regex.

Beginners coming to the world of Lua pattern matching often think they are using regex and are surprised to see a simple pattern like \d{3} fail to do what they expect to get. They are then told the correct pattern is %d%d%d. It's only confusing to tell them this is also a flavor of regex, one that isn't used in any other flavors of regex.

5
  • 5
    As hvd says, superficial syntax not a regex makes or breaks. There are fundamental features missing though. Commented Feb 7, 2016 at 12:43
  • 4
    If your definition of "regex" is so loose that it includes csh filename globs, something is obviously wrong.
    – user2404501
    Commented Feb 7, 2016 at 13:28
  • 1
    Arent't you arguing ANY regex language is ONLY a "true regex" if it uses * for zero-or-more, the backslash for escaping, etc.? Are you synonymizing regex not with "regular expression" but exclusively with "reasonably GREP-like"? (In which case, should we have a tag regular-expression which is wider than just plain regex?)
    – Jongware
    Commented Feb 7, 2016 at 13:40
  • @Jongware I'm arguing for what I think is common usage (excluding newcomers who don't yet know what's what): "regular expression" in programming context is about a particular family of pattern-matching languages with the UNIX editor ed as the progenitor. Many changes have occurred through the line of ed->grep/egrep->awk->perl->python/javascript and so on, but each new pattern matching language calling itself "regex" has been designed to be at least familiar to the users of, if not completely backward-compatible with, one of its predecessors in this family.
    – user2404501
    Commented Feb 8, 2016 at 13:56
  • I would just add here you're not guilty anymore for the rollback war as you came here trying to reason about it. You started, but decided to no keep it going ;) Commented Feb 9, 2016 at 2:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .