dudu
1
[backslash] / can be used like this [/每] in ttrss’s filter, this can filte the “/” or “每”, but I test it in some regex tools, it tells me [/每] is not ok, I should use [\/每], So which is correct?
With [\/每], the filter in ttrss is not correct though.

Firstly you’re describing a normal slash (/), not the backslash (\).
Secondly, / is commonly used to delimit a regular expression, so indeed if you want to use one inside a regex you need to escape it (using a backslash). Yes, even if inside a [] sequence.
As to why your regex “is not correct though”. What is it you’re trying to achieve? What text is this meant to match (and not match) against ?
dudu
3
I want match “/年” or “每年”, I usually use “[\/每]年”, this works in most PCRE support tools,no error.
But I can’t use it in ttrss’s filter.
ttrss’s filter only works with [/每]年, this can match “/年” or “每年”, so I say it’s weird.
TT-RSS uses slashes (/) as regex delimiters and automatically escapes any slashes within the expression itself:
from /classes/rssutils.php
foreach ($filter["rules"] as $rule) {
$match = false;
$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
$rule_inverse = $rule["inverse"];
... }
So just write your expression without escaping the slashes and it should work.
For testing with Regex101 you can change the delimiter to a character which is not used within your expression. Just click on the delimiter and select one.
Depending on what regexp characters are allowed in the input, perhaps ‘preg_quote’ is better. (?)
https://www.php.net/manual/en/function.preg-quote.php
fox
6
how exactly are we going to match things to a quoted regular expression?
e: slash is quoted explicitly only because it’s a delimiter
An infinitely recursive strpos() function.
dudu
9
Thanks all you guys’ replies.
I post this only want to know whether it’s a bug or not.
It seems not a bug, that’s fine.