Skip to main content
Question

Issue with StringReplacer

  • September 27, 2023
  • 3 replies
  • 31 views

gruelle88
Contributor
Forum|alt.badge.img+13

I have an excel containing 3 columns with name of Belgian commune in 3 format : one with dash (ex Saint-Nicolas), one its regex counterpart (\\bSaint-Nicolas\\b), and one without dash (Saint Nicolas). My goal is to replace, in a feature layer, the attribute with the dash by the one without the dash. So, for this, I am using a conditional replacement in attributeManager, but it fails ( @ReplaceString(@Value(attributeToReplace),@Value(xls_regex),@Value(xls_FinalName),caseSensitive=TRUE). It seems that it doesn't recognize that the attribute fulfill the condition. But, if I put my condition manually, one commune at a time (attributeToReplace Contains \\bSaint-Nicolas\\b, etc.), it does work !

 

What am I missing here ?

3 replies

ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • September 27, 2023

You need to use ReplaceRegEx if you want to replace regex

@ReplaceRegEx(@Value(attributeToReplace),@Value(xls_regex),@Value(xls_FinalName),caseSensitive=TRUE)

 

 


gruelle88
Contributor
Forum|alt.badge.img+13
  • Author
  • Contributor
  • October 4, 2023

You need to use ReplaceRegEx if you want to replace regex

@ReplaceRegEx(@Value(attributeToReplace),@Value(xls_regex),@Value(xls_FinalName),caseSensitive=TRUE)

 

 

 

Thx for your supportReplaceRegExThat's also what I did, but it seems that it doesn't recognise that the xls_regex value is contained in attributeToReplace.

However, If I "hardcode" the regex value to be replaced, let's say \bBeyne-Heusey\b, it's ok. So I guess the regex value from the xls file is not read as expected.

 


ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • October 4, 2023

Your statement won't work as the features containing the text to replace don't also contain the regex.