Loading...

verticapy.sql.functions.regexp_like#

verticapy.sql.functions.regexp_like(expr: str | list[str] | StringSQL | list[StringSQL], pattern: str | list[str] | StringSQL | list[StringSQL]) StringSQL#

Returns true if the string matches the regular expression.

Parameters#

expr: SQLExpression

Expression.

pattern: SQLExpression

A string containing the regular expression to match against the string.

Returns#

StringSQL

SQL string.

Examples#

For this example, we will use the Titanic dataset.

from verticapy.datasets import load_titanic

titanic = load_titanic()

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

Now, let’s import the VerticaPy SQL functions.

import verticapy.sql.functions as vpf

Now, let’s go ahead and apply the function.

titanic["has_title"] = vpf.regexp_like(
    titanic["name"],
    '([A-Za-z])+\.',
)
display(titanic[["name", "has_title"]])
Abc
Varchar(164)
100%
010
has_title
Boolean
100%
1
2
3
4
5

Note

It’s crucial to utilize VerticaPy SQL functions in coding, as they can be updated over time with new syntax. While SQL functions typically remain stable, they may vary across platforms or versions. VerticaPy effectively manages these changes, a task not achievable with pure SQL.

See also

vDataFrame.eval() : Evaluates the expression.