Unnecessary use of .* in examples

Поиск
Список
Период
Сортировка
От PG Doc comments form
Тема Unnecessary use of .* in examples
Дата
Msg-id 161215841824.14653.8969016349304314299@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: Unnecessary use of .* in examples  (Laurenz Albe <laurenz.albe@cybertec.at>)
Список pgsql-docs
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/13/functions-matching.html
Description:

In the table for the ~ (and friends) operator, every example has a pointless
set of '.*' surrounding the text to be matched. These unnecessary operators
add visual clutter making the examples both harder to read and understand,
and since they're official examples, they teach bad habits.

That is to say, 'thomas' ~ 'thom' is the exact same regex as 'thomas' ~
'.*thom.*' but the first is shorter, easier to read and easier to
understand, and, presumably, faster as well.

Operator

Description

Example(s)

text ~ text → boolean

String matches regular expression, case sensitively

'thomas' ~ '.*thom.*' → t

text ~* text → boolean

String matches regular expression, case insensitively

'thomas' ~* '.*Thom.*' → t

text !~ text → boolean

String does not match regular expression, case sensitively

'thomas' !~ '.*thomas.*' → f

text !~* text → boolean

String does not match regular expression, case insensitively

'thomas' !~* '.*vadim.*' → t

В списке pgsql-docs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: is_local parameter on set_config function
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: Unnecessary use of .* in examples