tf.strings.regex_full_match
Stay organized with collections
Save and categorize content based on your preferences.
Check if the input matches the regex pattern.
tf.strings.regex_full_match(
input, pattern, name=None
)
Used in the notebooks
The input is a string tensor of any shape. The pattern is a scalar
string tensor which is applied to every element of the input tensor.
The boolean values (True or False) of the output tensor indicate
if the input matches the regex pattern provided.
The pattern follows the re2 syntax (https://github.com/google/re2/wiki/Syntax)
Examples:
tf.strings.regex_full_match(["TF lib", "lib TF"], ".*lib$")
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])>
tf.strings.regex_full_match(["TF lib", "lib TF"], ".*TF$")
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([False, True])>
Args |
input
|
A Tensor of type string .
A string tensor of the text to be processed.
|
pattern
|
A Tensor of type string .
A scalar string tensor containing the regular expression to match the input.
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor of type bool .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.strings.regex_full_match\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/string_ops.py#L47-L69) |\n\nCheck if the input matches the regex pattern.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.strings.regex_full_match`](https://www.tensorflow.org/api_docs/python/tf/strings/regex_full_match)\n\n\u003cbr /\u003e\n\n tf.strings.regex_full_match(\n input, pattern, name=None\n )\n\n### Used in the notebooks\n\n| Used in the guide |\n|----------------------------------------------------------------------------------|\n| - [Subword tokenizers](https://www.tensorflow.org/text/guide/subwords_tokenizer) |\n\nThe input is a string tensor of any shape. The pattern is a scalar\nstring tensor which is applied to every element of the input tensor.\nThe boolean values (True or False) of the output tensor indicate\nif the input matches the regex pattern provided.\n\nThe pattern follows the re2 syntax (\u003chttps://github.com/google/re2/wiki/Syntax\u003e)\n\n#### Examples:\n\n tf.strings.regex_full_match([\"TF lib\", \"lib TF\"], \".*lib$\")\n \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([ True, False])\u003e\n tf.strings.regex_full_match([\"TF lib\", \"lib TF\"], \".*TF$\")\n \u003ctf.Tensor: shape=(2,), dtype=bool, numpy=array([False, True])\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------|-----------------------------------------------------------------------------------------------------------|\n| `input` | A `Tensor` of type `string`. A string tensor of the text to be processed. |\n| `pattern` | A `Tensor` of type `string`. A scalar string tensor containing the regular expression to match the input. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` of type `bool`. ||\n\n\u003cbr /\u003e"]]