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 next

...

Column reference example:

RIGHTFIND
d-codelang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:
rightfind(MyName,'find this',true,0)

rightfind(MyName,'find this',true,0)

Output: Searches the MyName column value for the last instance of the string find this from the end of the value, ignoring case. If a match is found, the index value from the beginning of the string is

...

returned.

String literal example:

RIGHTFIND
d-codelang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:
rightfind('Hello, World','lo',false,2)

rightfind('Hello, World','lo',false,2)

Output: Searches the string Hello, World for the string lo, in a case-sensitive search from the third-to-last character of the string. Since the match is found at the fourth character from the left, the value 3 is

...

returned.

If example:

IFRIGHTFIND
d-codelang-syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:
if(
rightfind(SearchPool,'FindIt') >= 0, 'found it', '') as: 'Finds'

if(rightfind(SearchPool,'FindIt') >= 0, 'found it', '')

Output: Searches the SearchPool column value for the string FindIt from the end of the value (default). Default behavior is to not ignore case. If the string is found,

...

 the value found it is returned. Otherwise, the

...

value is empty.

D s
snippetSyntax

RIGHTFIND
d-codelang-syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:
rightfind(column_string,string_pattern,[ignore_case], [start_index])

rightfind(column_string,string_pattern,[ignore_case], [start_index])


ArgumentRequired?Data TypeDescription
column_stringYstringName of the column or string literal to be applied to the function
string_patternYstringString literal or pattern to find
ignore_caseNbooleanIf true, a case-insensitive match is performed. Default is false.
start_indexNinteger (non-negative)

If specified, this value identifies the start index value of the source data to search for a match.

Info

NOTE: This value is specified from the end of the string.

 

If not specified, the entire string is searched.

...

URL
www.example.com
http://www.example.com
http://www.example.com/test_app
http://www.example.com/index.html
http://www.example.com/resources/mypic.jpg
http://www.example.com/pages/mypage.html
http://www.example.com/resources/styles.css
www.example.com/resources/styles.css

TransformTransformation:

To preserve the original column, you can use the following to create a working version of the source:

d-

...

trans
RawWrangletrue
p03Value'filename'
Typestep
WrangleTextderive type:single value:URL as:'filename'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02ValueURL
p03NameNew column name
SearchTermNew formula

You can use the following to standardize the formatting of the working column:

d-

...

trans
RawWrangletrue
p03Value''
Typestep
WrangleTextreplace: col:filename on:'http:' with:'' ignoreCase:true
p01NameColumn
p01Valuefilename
p02NameFind
p02Value'http:'
p03NameReplace with
p04Valuetrue
p04NameIgnore case
SearchTermReplace text or pattern

Tip

Tip: You may need to modify the above to use a

D s item
itempattern
to also remove https://.

The next two steps calcuate calculate where in the filename values the forward slash and dot values are located, if at all. The following calculates the:

d-

...

trans
RawWrangletrue
p03Value'rightFindSlash'
Typestep
WrangleTextderive type:single value:

...

rightfind(filename,"\/",true,0) as: 'rightFindSlash'

...

p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuerightfind(filename,"\/",true,0)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'rightFindDot'
Typestep
WrangleTextderive type:single value:

...

rightfind(filename,".",true,0) as: 'rightFindDot'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valuerightfind(filename,".",true,0)
p03NameNew column name
SearchTermNew formula

If either of the above values is 0, then there is no filename present:

 

d-

...

trans
RawWrangletrue
Typestep
WrangleTextset col:filename value:

...

if((rightFindSlash == 0) || (rightFindDot == 0), '',

...

right(filename,(

...

len(filename)-rightFindSlash)))
p01NameColumns
p01Valuefilename
p02NameFormula
p02Valueif((rightFindSlash == 0) || (rightFindDot == 0), '', right(filename,(len(filename)-rightFindSlash)))
SearchTermEdit column with formula

Results:

After removing the intermediate columns, you should end up with something like the following:

...