Skip to main content

Hi,

i like to create a new Attribute in the AttributeManager using a string function like the StringSearchers FirstMatch.

Is there anything similar as string function?

e.g.:

Input: 102464, 12345, 123478

Regexp: ^\\d*

RegExp-Match: 102464

Desired output: 102464

Greetings Hendrik

Hi @hendrik, try this expression.

@ReplaceRegEx(@Value(source),^(\d*).*,\1)

Hi @hendrik, try this expression.

@ReplaceRegEx(@Value(source),^(\d*).*,\1)

Hi @takashi gerat it's working - but i don't understand.

^(\d*) matches the first digits 

.* the rest of the string

\1 sould be the replacement sting

can you explain it to me?


Hi @takashi gerat it's working - but i don't understand.

^(\\d*) matches the first digits

.* the rest of the string

\\1 sould be the replacement sting

can you explain it to me?

That's right. \\1 indicates the substring that matches the first sub regex (i.e. the partial expression surrounded by round parens).

 

The function is equivalent to the StringReplacer (Mode: Replace Regular Expression).

 


Hi @takashi gerat it's working - but i don't understand.

^(\\d*) matches the first digits

.* the rest of the string

\\1 sould be the replacement sting

can you explain it to me?

Is there any documentation for this feature?

 

This is something i assumed to be part of the FindRegEx function. 😉

 


Is there any documentation for this feature?

 

This is something i assumed to be part of the FindRegEx function. 😉

 

FindRegEx returns the location of the match, not the match itself

 

 


Hi @takashi gerat it's working - but i don't understand.

^(\\d*) matches the first digits

.* the rest of the string

\\1 sould be the replacement sting

can you explain it to me?

See here to learn more about FME String Functions: Workbench String Functions

 

 


See here to learn more about FME String Functions: Workbench String Functions

 

 

This is the standard help for the string functions the \\1 parameter isn't documented there. Maybe someone @safe will take care about that in the future.

 


Hi @takashi gerat it's working - but i don't understand.

^(\\d*) matches the first digits

.* the rest of the string

\\1 sould be the replacement sting

can you explain it to me?

\\1 (numbered backreference) is a standard in regular expressions, is not a standard of FME.

 

Regular-Expressions.Info > Replacement String Tutorial > Numbered Backreferences

 

The Help on the StringReplacer mentions it too.

 


Reply