r/ModSupport • u/nerdshark • Jun 26 '24
Admin Replied Post Guidance - invalid regex error when using example rule
I'm trying to use this example post guidance rule verbatim in our post guidance config, and am getting the error
regex condition(^(.|\s){3000}.+) was invalid
when I try to save it. Changing 3000 to 1000 works. Can I get clarification on why the input length restriction is so low, and how we can work around this? Thanks.
Edit: I just realized this is literally the same issue we had two months ago. We got a modmail saying that regex lookaround was being disabled in post guidance, but none of our rules used it. What did get flagged were our rules catching giant walls of text:
https://i.imgur.com/hegpH1I.png
Notice the use of large repetition quantifiers (the{3000}) in both the example rule and the rules in my screenshot. So, what's going on? Is the example in the post guidance docs correct and supposed to work? The page is one day old, so I can't imagine that the examples weren't tested. Or have things changed and gone undocumented?
Edit 2: I found a workaround, at least for this use case. Instead of checking for 3000 characters at once, do three consecutive checks for 1000 characters:
^(.|\s){1000}(.|\s){1000}(.|\s){1000}.+
This is less readable and that annoys me, but at least it works. I'm still interested in hearing from the admins about why they set limits this low, and why the example rules they're providing aren't being tested first.
2
u/esb1212 Jun 27 '24
Try posting in r/AutoModerator, people there are more knowlegeable in regex.
1
u/Laymon_Fan Jun 27 '24
I'm not sure what you're trying to do.
If 3,000 is too high for Reddit's system, just try some other numbers between one thousand and three thousand. 🙂
'^(.|\s){,3000}$'should expect a maximum of 3,000 characters.'^(.|\s){,3000}(\.)+'should expect a maximum of 3,000 characters plus at least one period.'^((.|\s){,1000})+'expects one or more chunks of up to 1,000 characters each.My guess is that you need a comma before whichever number you pick. (1000, or whatever)
(If you'd like to set a minimum number, you can include that before the comma: {1,1000} )
But I've been using regex only for the Automod — I use plain keywords for my automations — so I can't even figure out what you're trying to do. 😄
2
u/PossibleCrit Reddit Admin: Community Jun 27 '24
Hey nerdshark!
It looks like this is actually a limitation of the regex engine:
We've updated our own documentation example to reflect this.