Skip to main content
Question

Using Regex within AttributeValidator to match anything but X string


Forum|alt.badge.img

I am sure this is a simple fix for this, but I've been testing this for hours now and going nowhere!

In AttributeValidator, I want to FAIL an attribute which contains a certain string. The most logical thing I could think of is to use the Contains Regex validation rule. Let's say I want to 'Fail' every attribute where it contains a string which = FME. I have trawled the internet and got the following expression to work within the Regex Editor:

\\b(?!FME)\\b\\S+

However, when it runs in the AttributeValidator, attributes which i have engineered to contain FME, appears from the Passed output port.

1. Is there a much simpler way within the AttributeValidator to fail any attribute which contains a certain string, rather than regex?

2. If not, am I doing something fundamentally wrong with the Regex or validation rule?

Thanks

4 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • August 7, 2018

[^fme] should work for everything except fme

Edit: although it doesn't appear to....


Forum|alt.badge.img
  • Author
  • August 7, 2018
ebygomm wrote:

[^fme] should work for everything except fme

Edit: although it doesn't appear to....

Thanks, @egomm that works! However, what I should have put in the question above was that there could be other string in the attribute, e.g, MEF and [^fme] would include this as well. What i need is a string only match and it looks like that is a character match?

 


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • August 7, 2018
johnwk wrote:
Thanks, @egomm that works! However, what I should have put in the question above was that there could be other string in the attribute, e.g, MEF and [^fme] would include this as well. What i need is a string only match and it looks like that is a character match?

 

Try ^(?!.*fme).*$

 

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • August 7, 2018
johnwk wrote:
Thanks, @egomm that works! However, what I should have put in the question above was that there could be other string in the attribute, e.g, MEF and [^fme] would include this as well. What i need is a string only match and it looks like that is a character match?

 

Additionally, if word boundaries are required before and after 'FME', try this one.

 

^(?!.*\bFME\b).*$

 


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