39

A question I posted an answer to was deleted: Why does a regex using an unescaped dash - character not seem to work in a pattern attribute in HTML but it works when testing on regex101? (Screenshot of question and my answer).

The deleted question is also closed as a duplicate of Why is my regex valid with the RegExp u flag, but not with the v flag and does not work in HTML pattern attribute? however, in my opinion, it only partially overlaps. My answer does not apply directly to the duplicate.

What the question is about (background information):

The core of the issue is that there is a new flag for regular expressions introduced in JavaScript - previously there was a u flag for handling Unicode characters and recently a v flag was introduced which allows for far more flexibility in writing the regular expressions. That is what the duplicate target is about.

While v has basically the same capabilities of u but it also has extra features it is almost a straight upgrade. It does come with slightly stricter syntax that means that some older patterns would be invalid. What I think is going to be common is a character class that includes a dash, for example [ab-] - it is common and idiomatic usage to put the dash at the either end of the character class to make sure it is interpreted as a dash and not a range. Otherwise it would need to be escaped, e.g., [a\-b]. However, with the v flag a dash always needs escaping, so a correct pattern is [ab\-]

Why I think the HTML part is distinct and worth preserving

However, the closed and now deleted question was asking about the HTML pattern attribute which takes a regular expression and validates user input against it. The HTML specification was changed rather recently in April 2023 to now mandate that values of pattern be used with the v flag. Thus one could run into the u vs v discrepancy separate from the JavaScript change entirely.

This is indeed how I came across it - while researching for my answer. As a result, I also had to return to an older work application and make sure it still works since it uses HTML validation but it is configurable. I had to make sure that it would not throw errors for configurations that previously worked and has to keep on working.

This, I feel, is information absolutely worth preserving - the fact that the HTML specification has been changed and when as it would be useful for others that might be in my situation.

There are more ways this can be encountered, not only with old (pre-April 2023) applications but also older (pre-April 2023) tutorials, references, lectures, documentation that might use a now-invalid pattern.

That was the case with the now deleted question - the asker took the code from a textbook which was valid for when it was published.

While the differences between the u and v flags are absolutely relevant, I do not think the JavaScript answer to that is directly applicable to HTML questions. It is a component of the answer, not the whole thing.


This is why I believe the deleted information is relevant and belongs to be included in a library of useful programming topics.

Can it be preserved and how?

  • Undeleting the question?
  • Posting a new Q&A that focuses more on the HTML side of thing?
  • Something else entirely?

Or just do nothing?

16
  • 6
    The part about HTML specs was recently added to the only answer of the dupe target. Coincidence?
    – InSync
    Commented Jan 4 at 14:04
  • 23
    I don't know if it's a duplicate or not, but it should not have been deleted in either case
    – Bergi
    Commented Jan 4 at 14:21
  • 3
    @InSync what matters is that it's a good edit. (If a poster wants to expand and improve their answer that's good.)
    – bad_coder
    Commented Jan 4 at 14:26
  • 1
    @bad_coder I'm not saying it's good or bad; I'm asking if there is a coincidence.
    – InSync
    Commented Jan 4 at 14:35
  • 5
    @InSync likely not and that's irrelevant. I wish every poster kept their contributions up-to-date for the reader's benefit.
    – bad_coder
    Commented Jan 4 at 14:38
  • 15
    I don't see anything wrong with it being closed as a dupe, but i also don't see a reason for it to be deleted, It is ultimately the same problem, but the question that brought it is different enough for it to act as a good sign post.
    – Kevin B
    Commented Jan 4 at 15:39
  • 2
    The questions are the same. Both are about the use of a regex inside an HTML pattern attribute. Commented Jan 4 at 21:08
  • 22
    @WiktorStribiżew Whether or not it is a duplicate is not the question being asked. The question being asked is why it was necessary to delete it? Neither the question nor the answer were bad enough to warrant deletion. The question is subtly different from the duplicate in that it focuses on the historical aspect of code that was once valid and published in a book and now is invalid and the answer certainly adds value to SO as it explains both why the code is now invalid and the historical changes than have changed its validity.
    – MT0
    Commented Jan 4 at 23:53
  • 13
    @WiktorStribiżew before your edit, the duplicate was solely focused on the JavaScript aspect the flags and how they change the interpretation of the patterns. That changed few hours before the question I answered was deleted. Until then I'd not have posted my answer to the duplicate because it wasn't a suitable target for the HTML side of this query. I did add a reference to it in my answer because it was an excellent addition showing the full impact of the v flag. I have to confess, I didn't notice that the question and answer were changed when I started writing the meta post.
    – VLAZ
    Commented Jan 5 at 8:22
  • 11
    "Or just do nothing?" - heck no. Always create a meta beauty just like this. The more of these posts we have, the more chance someone sees it and adjusts their idea of what deserves to be deleted.
    – Gimby
    Commented Jan 5 at 10:56
  • 10
    It would be interesting to see what any of the delete voters thought about the question (~12 upvotes) and answer (~13 upvotes) that warranted deletion. Or was deletion just an underhanded way to prevent a second reopening (now achieved)? If the latter, then it's a blatant abuse of the delete vote privilege. Commented Jan 6 at 11:44
  • 8
    it seems like there's been a lot of controversy surrounding the deletes which @WiktorStribiżew has made, going back a number of years. I saw on a previous answer Wiktor explained their system/thought process around closing and/or deleting. Though I'm sure the denominator is large, it's hard not to look at the many people who disagree with Wiktor's decisions and think there is something fundamentally wrong, either with Wiktor's system or with the policies of SO in general
    – Mark
    Commented Jan 6 at 14:50
  • 2
    Tons of related questions, long ongoing problem largely created by a single "power" user who's singlehandedly ruined the tag: 1, 2, 3, 4, 5. I've been upvoting these complaints for years but nothing ever really changes. The only solution is probably disciplinary action against the user--hate to say it, but that's the way it is.
    – ggorlen
    Commented Jan 7 at 19:09
  • @mark this answer, I guess. At least the dude explained himself to a pretty amazing detail, there are plenty others that just evade any opportunity to account for their actions. I wish everyone good luck trying to make such a person a villain. What might be missing is a little more policy around tag lording. Being a gold badger is a high honor, but don't make yourself lord of the realm.
    – Gimby
    Commented Jan 10 at 14:14
  • @Gimby exactly. I would say the "aggressive cleaning" approach is unpopular and unhelpful, but that's my opinion
    – Mark
    Commented Jan 11 at 6:58

1 Answer 1

14

The Question and Answer have been undeleted.

0

You must log in to answer this question.

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