Sql 一个众所周知的事实,是一个众所周知的事实,是一个众所周知的事实,是一个已知的事实,是一个已知的是,是是的????????????(一个众所周知的事实,是一个已知的事实,是一个已知的事实,是一个已知的一个已知的事实,是一个已知已知的一个已知的一个已知的事实,
Sql 一个众所周知的事实,是一个众所周知的事实,是一个众所周知的事实,是一个已知的事实,是一个已知的是,是是的????????????(一个众所周知的事实,是一个已知的事实,是一个已知的事实,是一个已知的一个已知的事实,是一个已知已知的一个已知的一个已知的事实,,sql,regex,mariadb,mediawiki,recursive-query,Sql,Regex,Mariadb,Mediawiki,Recursive Query,一个众所周知的事实,是一个众所周知的事实,是一个众所周知的事实,是一个已知的事实,是一个已知的是,是是的????????????(一个众所周知的事实,是一个已知的事实,是一个已知的事实,是一个已知的一个已知的事实,是一个已知已知的一个已知的一个已知的事实,是,是一一个已知的一个已知的一个已知的一个已知的事实,是,是,是一一个已知的一个已知的一个已知的一个已知的一个已知的一个已知的事实,是,是,是,是,是,是,是一个已知的一个已知的一个已知的一个已知的事实,是,是,是,是,是,是,是,是,是,是,
一个众所周知的事实,是一个众所周知的事实,是一个众所周知的事实,是一个已知的事实,是一个已知的是,是是的????????????<代码>(一个众所周知的事实,是一个已知的事实,是一个已知的事实,是一个已知的一个已知的事实,是一个已知已知的一个已知的一个已知的事实,是,是一一个已知的一个已知的一个已知的一个已知的事实,是,是,是一一个已知的一个已知的一个已知的一个已知的一个已知的一个已知的事实,是,是,是,是,是,是,是一个已知的一个已知的一个已知的一个已知的事实,是,是,是,是,是,是,是,是,是,是,是,是,是,是,是,是,是,是,是是是是是是是是是一名名名名名名名名名名\2)(*)+?*(?=\1)(?:(?!{.)*(?=\2$)其中点匹配全部设置第一个解决方案匹配页面中的所有模板(无论模板名称如何,所以不是我们想要的),第二个和第三个解决方案匹配页面中的所有模板({WoodhouseENELnames([^{}]*{([^{}])*{{((3)*(2))*}(3)*}(3)*}}})(第三个解决方案持续了10分钟),只匹配了包含此模板的部分页面,但匹配正确。我猜他们错过了一些具有多个换行符的较长模板。我可以看到,MariaDB 10.3支持PCRE,但不支持10.5中支持的PCRE2
{{WoodhouseENELnames
|Text=[[File:woodhouse_999.jpg|thumb|link={{filepath:woodhouse_999.jpg}}]]Αἰακός, ὁ, or say, son of Aegina.
<b class="b2">Of Aeacus</b>, adj.: Αἰάκειος.
<b class="b2">Descendant of Aeacus</b>: Αἰακίδης, -ου, ὁ.
}}
{{MyTemplatename
|Text=text, text, text
}}
{{WoodhouseENELnames
|Text=text, text, text
}}
{{OtherTemplatename
|Text= text, text, text
}}
with recursive cte as (
select
n_open n0,
n_open n1,
1 cnt,
mycol,
id
from (select t.*, locate('{{WoodhouseENELnames', mycol) n_open from mytable t) x
where n_open > 0
union all
select
n0,
n1 + 2 + case when n_open > 0 and n_open < n_close then n_open else n_close end,
cnt + case when n_open > 0 and n_open < n_close then 1 else -1 end,
mycol,
id
from (
select
c.*,
locate('{{', substring(mycol, n1 + 2)) n_open,
locate('}}', substring(mycol, n1 + 2)) n_close
from cte c
) x
where cnt > 0
)
select id, concat(substring(mycol, 1, min(n0) - 1), substring(mycol, max(n1) + 1)) mycol
from cte
group by id
create table mytable(id int, mycol varchar(2000));
insert into mytable values (
1,
'{{abcd{{WoodhouseENELnames
|Text=[[File:woodhouse_999.jpg|thumb|link={{filepath:woodhouse_999.jpg}}]]Αἰακός, ὁ, or say, son of Aegina.
<b class="b2">Of Aeacus</b>, adj.: Αἰάκειος.
<b class="b2">Descendant of Aeacus</b>: Αἰακίδης, -ου, ὁ.
}} efgh{{'
);
id | mycol
-: | :------------
1 | {{abcd efgh{{
(?ms)^{{WoodhouseENELnames.+?^}}
(?msx)
({{WoodhouseENELnames # group 1: Matching the whole template
( # group 2: Mathing the contents of the Template, including subpatters.
[^{}]* # Search zewro or more characters except { or }
{{ # The beginning of a subpattern
( # Containg if:
[^{}]++ # Search zewro or more characters except { or }
| (?2) # or the recursive pattern group 2
)* # Zero or more times
}} # The closing of the subpattern.
[^{}]* # Search zewro or more characters except { or }
)
}}
)
(?msx) # Note the additional 'x'-Option, allowing free spacing.
({{WoodhouseENELnames # Searcdh group 1 - Top level template:
( # Search group 2 - top level template contents:
( # Search-group 3 - Subtemplate contents:
[^{}]* # Zero or more characters except { or }
| {(?!{) # or a single { not follwed by a {
| }(?!}) # or a single } not follwed by a }
)* # Closing search group 3
{{ # Opening subtemplate tag
( # Search group 4:
(?3)* # Reusing serach group 3, zero or more times
| (?2) # or Recurse search group 2 (of which, this is a part)
)* # Group 4 zero or more times
}} # Closing subtemplate tag
(?3)* # Reusing search group 3, zero or more times
) # Closing Search group 2 - Template contents
}} # Top-level Template closing tag
) # Closing Search group 1