コード例 #1
0
def regex_full_match(input, pattern, name=None):
    r"""Match elements of `input` with regex `pattern`.

  Args:
    input: string `Tensor`, the source strings to process.
    pattern: string or scalar string `Tensor`, regular expression to use,
      see more details at https://github.com/google/re2/wiki/Syntax
    name: Name of the op.

  Returns:
    bool `Tensor` of the same shape as `input` with match results.
  """
    # TODO(b/112455102): Remove compat.forward_compatible once past the horizon.
    if not compat.forward_compatible(2018, 11, 10):
        return gen_string_ops.regex_full_match(input=input,
                                               pattern=pattern,
                                               name=name)
    if isinstance(pattern, util_compat.bytes_or_text_types):
        # When `pattern` is static through the life of the op we can
        # use a version which performs the expensive regex compilation once at
        # creation time.
        return gen_string_ops.static_regex_full_match(input=input,
                                                      pattern=pattern,
                                                      name=name)
    return gen_string_ops.regex_full_match(input=input,
                                           pattern=pattern,
                                           name=name)
コード例 #2
0
def regex_full_match(input, pattern, name=None):
  r"""Match elements of `input` with regex `pattern`.

  Args:
    input: string `Tensor`, the source strings to process.
    pattern: string or scalar string `Tensor`, regular expression to use,
      see more details at https://github.com/google/re2/wiki/Syntax
    name: Name of the op.

  Returns:
    bool `Tensor` of the same shape as `input` with match results.
  """
  # TODO(b/112455102): Remove compat.forward_compatible once past the horizon.
  if not compat.forward_compatible(2018, 11, 10):
    return gen_string_ops.regex_full_match(
        input=input, pattern=pattern, name=name)
  if isinstance(pattern, util_compat.bytes_or_text_types):
    # When `pattern` is static through the life of the op we can
    # use a version which performs the expensive regex compilation once at
    # creation time.
    return gen_string_ops.static_regex_full_match(
        input=input, pattern=pattern, name=name)
  return gen_string_ops.regex_full_match(
      input=input, pattern=pattern, name=name)