0

I am working on an XP machine with FME'13 and I have a Address field and I have to find the spaces(middle spaces and not the leading and trailing ) in each and every row.

St._Petters_Road is the valid space(it need not be flagged); but St.__Petters_Road is invalid (as it has two consecutive whitespaces).

It is assumed that the words are correct. But there should not be two two consecutive spaces.

and I need to flag the invalid attributes in a new column as 0 and 1 Can we do that with transformers or in SQL?

2

One option is use Tester with LIKE (operator) and '%__%' (right value) (passed)--> to AttributeCreator (add column changed, set value to 1) Or Tester with RegExp, but i dont know regexp that well that i can say correct value for it. You can use SQL too , it will be faster if you import data from sql db. (WHERE field LIKE '%__%')

If you want remove those __ from value field, then you can use StringReplacer with "Text to find" __ and Replace "_", or use regexp which may be able to handle all cases with too many _. If you don't want have that changed field you can just use StringReplacer.

Also if you meant _ to be just space then use % % in LIKE operator (see two spaces ) :) Same can be used in StringReplacer

edit: __ may not be correctly in answer because site seems to convert % and _ to bolded text

  • +1 for suggesting regexp. It could capture all instances of too many spaces instead of using multiple testers. – Fezter Feb 24 '14 at 23:01
  • @Fetzer , my regexp is weak. Can you show example for replace two or more characters with only one – simplexio Feb 25 '14 at 8:10
  • 1
    Use the StringReplacer transformer, set it to use regular expressions. Put in "\s{2,}" (without the quotes) to search for and your replacement text will be a single space. That will search for 2 or more whitespace characters. Safe software recommends Rubular.com to test regular expressions. You build your expression at the top and put your test string below. It's how I've taught myself regular expressions. – Fezter Feb 25 '14 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.