Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé
Classe « ColumnOperators »

Méthode sqlalchemy.ColumnOperators.regexp_match

Signature de la méthode regexp_match

def regexp_match(self, pattern: 'Any', flags: 'Optional[str]' = None) -> 'ColumnOperators' 

Description

help(ColumnOperators.regexp_match)

Implements a database-specific 'regexp match' operator.

E.g.::

    stmt = select(table.c.some_column).where(
        table.c.some_column.regexp_match("^(b|c)")
    )

:meth:`_sql.ColumnOperators.regexp_match` attempts to resolve to
a REGEXP-like function or operator provided by the backend, however
the specific regular expression syntax and flags available are
**not backend agnostic**.

Examples include:

* PostgreSQL - renders ``x ~ y`` or ``x !~ y`` when negated.
* Oracle Database - renders ``REGEXP_LIKE(x, y)``
* SQLite - uses SQLite's ``REGEXP`` placeholder operator and calls into
  the Python ``re.match()`` builtin.
* other backends may provide special implementations.
* Backends without any special implementation will emit
  the operator as "REGEXP" or "NOT REGEXP".  This is compatible with
  SQLite and MySQL, for example.

Regular expression support is currently implemented for Oracle
Database, PostgreSQL, MySQL and MariaDB.  Partial support is available
for SQLite.  Support among third-party dialects may vary.

:param pattern: The regular expression pattern string or column
  clause.
:param flags: Any regular expression string flags to apply, passed as
  plain Python string only.  These flags are backend specific.
  Some backends, like PostgreSQL and MariaDB, may alternatively
  specify the flags as part of the pattern.
  When using the ignore case flag 'i' in PostgreSQL, the ignore case
  regexp match operator ``~*`` or ``!~*`` will be used.

.. versionadded:: 1.4

.. versionchanged:: 1.4.48, 2.0.18  Note that due to an implementation
   error, the "flags" parameter previously accepted SQL expression
   objects such as column expressions in addition to plain Python
   strings.   This implementation did not work correctly with caching
   and was removed; strings only should be passed for the "flags"
   parameter, as these flags are rendered as literal inline values
   within SQL expressions.

.. seealso::

    :meth:`_sql.ColumnOperators.regexp_replace`




Vous êtes un professionnel et vous avez besoin d'une formation ? RAG (Retrieval-Augmented Generation)
et Fine Tuning d'un LLM
Voir le programme détaillé