Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ case class StringSplit(str: Expression, pattern: Expression)
usage = "_FUNC_(str, regexp, rep) - Replaces all substrings of `str` that match `regexp` with `rep`.",
extended = """
Examples:
> SELECT _FUNC_('100-200', '(\d+)', 'num');
spark-sql> SELECT _FUNC_('100-200', '(\\d+)', 'num');
num-num

scala> SELECT _FUNC_('100-200', '(\\\\d+)', 'num');
num-num
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scala> spark.sql("SELECT regexp_replace('100-200', '(\\d+)', 'num')").collect()
Array([num-num])

""")
// scalastyle:on line.size.limit
Expand Down Expand Up @@ -375,7 +378,10 @@ case class RegExpReplace(subject: Expression, regexp: Expression, rep: Expressio
usage = "_FUNC_(str, regexp[, idx]) - Extracts a group that matches `regexp`.",
extended = """
Examples:
> SELECT _FUNC_('100-200', '(\d+)-(\d+)', 1);
spark-sql> SELECT _FUNC_('100-200', '(\\d+)-(\\d+)', 1);
100

scala> SELECT _FUNC_('100-200', '(\\\\d+)-(\\\\d+)', 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scala> spark.sql("SELECT regexp_extract('100-200', '(\\d+)-(\\d+)', 1)").collect()

100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array([100])

""")
case class RegExpExtract(subject: Expression, regexp: Expression, idx: Expression)
Expand Down