Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r094

In

D toc

Excerpt

In 

D s lang
 transformations that support use of patterns, you may need to specify capture groups.

...

capture group

...

 is a pattern that describes a set of one or more characters that constitute a match. These matches can be programmatically referenced in replacement values.

  • These patterns are described using regular expression syntax. 
    D s product
     implements a version of regular expressions based off of RE2 and PCRE regular expressions.

...

D trans
RawWrangletrue
p03Value'First Word\:$1'
Typestep
WrangleTextreplace col:* on:`{start}(%+) ` with:'First Word\:$1'
p01NameColumnColumns
p01Value*All
p02NameFind
p02Value`{start}(%+) `
p03NameReplace with
SearchTermReplace text or pattern

...

ReferenceDescription
{start}

A

d-s-itemlang
itempattern
reference to the start of the tested value.

(%+)

Matches on one or more characters of any time.

Info

NOTE: The parentheses indicate that this set of characters is a capture group.

 Last character in the matching pattern is an empty space.

...

D trans
RawWrangletrue
p03Value'First Word\:$1'
Typestep
WrangleTextreplace col:* on:`{start}(%+) ( |{end})` with:'First Word\:$1'
p01NameColumnColumns
p01Value*All
p02NameFind
p02Value`{start}(%+) ( |{end})`
p03NameReplace with
SearchTermReplace text or pattern

...

ReferenceDescription
 first character in the second capture group is an empty space.
|Logical OR, which means that the capture group matches on either the empty space or the following value, which is a reference to the end of the tested value.
{end}

A

d-s-
item
lang
itempattern
reference to the end of the tested value.

...

D trans
RawWrangletrue
p03Value'Second Word\:$2'
Typestep
WrangleTextreplace col:* on:`{start}(%+) (%+)( |{end})` with:'Second Word\:$2'
p01NameColumnColumns
p01Value*All
p02NameFind
p02Value`{start}(%+) (%+)( |{end})`
p03NameReplace with
SearchTermReplace text or pattern

...

source valueReplace transformationreplacement
foobar

D trans
RawWrangletrue
p03Value'$$f'
Typestep
WrangleTextreplace col:MyColumn with:'$$f' on:'f'
p01NameColumn
p01ValueMyColumn
p02NameFind
p02Value'f'
p03NameReplace with
SearchTermReplace text or pattern

$foobar
foobar

D trans
RawWrangletrue
p03Value'$2'
Typestep
WrangleTextreplace col:MyColumn with:'$2' on:`(f)(o)o(b)ar`
p01NameColumn
p01ValueMyColumn
p02NameFind
p02Value`(f)(o)o(b)ar`
p03NameReplace with
SearchTermReplace text or pattern

Note that the on parameter is a

d-s-itemlang
itempatternrtrue
.

o

Positive and Negative Lookaheads

...

TypeExample expression 
Positive lookahead
Code Block
/q(?u)/
Capture the letter q only when it is followed by the letter u. Letter u is not captured.
Negative lookahead
Code Block
/q(?!u)/
Capture the letter q when it is not followed by the letter u. Letter u is not captured.

D s also
inCQLtrue
label((label = "group") OR (label = "references"))