Skip to main content
Solved

Multiple RegEx conditional values possible within AttributeManager?


Forum|alt.badge.img

Hello,

 

 

I'm trying to replace my overdose of RegEx StringReplacers with a single AttributeManager that should contains multiple RegEx functions.

 

 

I've set up a short test:

The first part of the test works fine: change: "world" to "WORLD"

 

The second part doesn't seem to execute: change the "99" to "100"

I'm now wondering:

 

Can the AttributeManager conditional value hold multiple RegEx functions or just one?

 

Thanks,

 

Ed

 

 

 

Best answer by arnovananrooij

You could try by adding multiple POI_NAME attributes, so with the same name. Each with one test.

View original
Did this help you find an answer to your question?

6 replies

redgeographics
Celebrity
Forum|alt.badge.img+47

I think what's happening is that the feature passes through the first IF statement, gets processed (changing world to WORLD) and then doesn't go through the others. Other than putting multiple AttributManagers (or StringReplacers) in a row I don't think there's much you can do about it.

Python could perhaps be an option if you want to run multiple regex replacements on a single attribute.


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • March 7, 2019

It's not very pretty or readable but you can do multiple regex replacements within the attributemanager with this sort of syntax

@ReplaceRegEx(@ReplaceRegEx(@Value(text),(World),WORLD),([0-9]{2}),100)

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • March 7, 2019

Hi @edhere, the conditions are evaluated one by one from top to bottom, and the evaluation process finishes when first matches or every not matches. The conditions that match the second or later will not be evaluated forever.

A workaround is to use the two StringReplacers in series, as @redgeographics mentioned.

Alternatively, this single expression could also work as expected. The @ReplaceRegEx function would return the original string if it didn't match the regex. 

@ReplaceRegEx(@ReplaceRegEx(@Value(POI_Name),World,WORLD),[0-9]{2},100)

 


arnovananrooij
Contributor
Forum|alt.badge.img+5
  • Contributor
  • Best Answer
  • March 7, 2019

You could try by adding multiple POI_NAME attributes, so with the same name. Each with one test.


Forum|alt.badge.img
  • Author
  • March 8, 2019

Thanks all for your comments.

 

I'm going for the solution by @arnovananrooij- this keeps a nice overview without having to write an extremely long RegEx.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • March 8, 2019
edhere wrote:

Thanks all for your comments.

 

I'm going for the solution by @arnovananrooij- this keeps a nice overview without having to write an extremely long RegEx.

Good to hear you got a solution.

In addition, you don't need to use conditional value setting here, since the @ReplaceRegEx function would just return the original string if it didn't match the regex.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings