Skip to main content
Solved

regex with attributevalidator - highlight "end wih new line"

  • February 21, 2020
  • 5 replies
  • 24 views

ronan
Participant
Forum|alt.badge.img+6
  • Participant

Hello,

I'm using attributevalidator to make multiple check on attributes.

There is one check I don't know how to implement. I would like to hightlight the attributes finishing with newline. I used this regex : [^(\\n)]$ . It is working when I use external tools (for example (https://regexr.com/ ), but not in FME. I didn't find any other regex to do that (I'm a beginner in regex).

In case, there is one other solution : using tester/attributecreator, but if possible, I would like to gather all the tests in the same transformer to make the workflow as simple as possible (the workflow contains a lot of attribute / spatial tests)

 

Thank you

 

 

Best answer by ebygomm

Try, if you just want to fail strings ending in a newline

[^\n]\z
View original
Did this help you find an answer to your question?

5 replies

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • February 21, 2020

If you want to find anything where the last character is a newline try

.*\n$

Edit: or are you looking for a statement so that anything ending in a newline comes out the failed port?


ronan
Participant
Forum|alt.badge.img+6
  • Author
  • Participant
  • February 21, 2020

Thank you, but I would like anything ending with a newline comes out the failed port. Then the workbench would provide automatically a report listing the objects that doesn't respect the rules described in the attributevalidator transformer.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • Best Answer
  • February 21, 2020

Try, if you just want to fail strings ending in a newline

[^\n]\z

ronan
Participant
Forum|alt.badge.img+6
  • Author
  • Participant
  • February 21, 2020

Thanks a lot :-). The following regex you provide me works perfectly !

[^\n]\z

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • February 21, 2020
ronan wrote:

Thanks a lot :-). The following regex you provide me works perfectly !

[^\n]\z

Matching end of lines and new lines differs depending on the underlying regex flavour, which is why you were getting differing results with external tools. The above for example, wouldn't work if you were trying to use the regex in python. 


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