0

In FME I have the following in the AttributeManager transformer to replace a value in a column

@ReplaceRegEx(@Value(Street_Address),"^([UNITunit]*.?\d+[\/-]?\d*\w).*",\1)

This should work as in the example in

https://regex101.com/r/CwKOSx/3

But instead it's doing the following

Truncated value `1 Keith Williams Drive CARDWELL QLD 4849' for column `Street_No' of MapInfo TAB file `\\sipv-gis01\Projects\Jobs\2019.0225_Property Update Automation\Working\FME_Scratch\Property_w2.tab' to the column's defined width of 26
Truncated value `Foxtail Avenue CARDWELL QLD 4849' for column `Street_No' of MapInfo TAB file `\\sipv-gis01\Projects\Jobs\2019.0225_Property Update Automation\Working\FME_Scratch\Property_w2.tab' to the column's defined width of 26
Truncated value `Unit 1/15 Keith Williams Drive CARDWELL QLD 4849' for column `Street_No' of MapInfo TAB file `\\sipv-gis01\Projects\Jobs\2019.0225_Property Update Automation\Working\FME_Scratch\Property_w2.tab' to the column's defined width of 26

Where I need the following for these

1
[no value]
Unit 1/15

I am not sure if this is a regex or fme question but how do I get it to show just the first match.

UPDATE

Using String Searcher with regex

^(UNIT\s)?\d+[-/]?\d*\w*

enter image description here

I get mostly correct output except enter image description here

The model is as below enter image description here

1 Answer 1

1

It would help to know which FME version you are using, because I'm using 2019 (2019.0.0.1, build 19246) and it seems to work more or less OK for me.

enter image description here

Plus I think there was a change around FME2018 about how we matched strings with regular expressions.

I'm guessing those messages are appearing when you write the data, and don't come from the AttributeManager. If you disabled the writer, do you get the same messages? I'd think not. So inspect the data coming out of the AttributeManager, and see what the result is.

I think there are two possible issues. One is that the AttributeManager is not set up correctly (are you using that expression on the attribute itself or creating a new attribute?). It also might be that FME returns the entire string as being a match (rather than just the part that matches).

So, like I said, it works for me. But another - maybe better method - would be to use the StringSearcher:

enter image description here

Having a list is what helps us here. It contains only the parts that match:

enter image description here

You just copy/rename the first part of that list to get what you need. It also helps that the StringSearcher divides the data into matched/not matched.

So I'd suggest:

  1. Checking the current AttributeManager output to see what it returns
  2. Checking the AttributeManager setup to see if anything is incorrect
  3. Trying the StringSearcher transformer instead
6
  • I am using v2019 - the fmw with the settings I used is in the following link. I just had it as expression in the AttributeManager. It's in the last step when writing the final tab file. drive.google.com/open?id=1a1GAf1x1ocD_uy8rQ9XzeasiuDWyiNcw
    – GeorgeC
    Commented Jun 28, 2019 at 7:28
  • I'm going to add this as an edit to my answer, just to give me some more space than just a comment. See above shortly... Commented Jun 28, 2019 at 15:50
  • Actually not. I thought I had found the reason, but no. Using the regex in your original question (different to the one in your workspace) it all works fine for me. I tried adjusting the attribute order in the transformer (made no difference), I tried with Street_No having a prior value (or not), using attribute names exactly the same as yours, etc, etc. All seems good. Can you try running this workspace and see if it gives you the result you expect: dropbox.com/s/5xs9v4wnh0rj3v1/ReplaceRegexTest.fmw?dl=1 Commented Jun 28, 2019 at 16:27
  • 1
    But I would really recommend the StringSearcher as a solution. Much easier to figure out and to test. Commented Jun 28, 2019 at 16:35
  • you are correct in that the attribute manager works fine when it's run by itself but not in writer. I switched to using string searcher and it almost works but it's dropping the /- in street numbers so "31/4 XX st" becomes "4 XX st", "16-18 YY St" becomes "1618 YY St" etc. I'll update the question with details/screen grabs.
    – GeorgeC
    Commented Jun 30, 2019 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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