Solved

Split text attribute based on attribute value

  • 18 June 2018
  • 3 replies
  • 14 views

Badge +11

Hi, I'm trying to split some text, based on the value auf another attribute. Unfortunately the AttributeSplitter transformer doesn't accept attribute values comming from inside the workspace, only pubulished parameters as the delimeter. Is there a way to set up individual delimeters for every feature and carry out the splitting upon them?

One Example:

Text_line_data: 2018-06-11 08:39:23| 486.7| 0.0|STATS |62b88ad3-1c54-43b2-b010-479f2141a98a Here comes the text string im interested in. The string wil vary in length for every feature

Desired delimiter: 62b88ad3-1c54-43b2-b010-479f2141a98a

 

I',m looking for the string that succeeds 62b88ad3-1c54-43b2-b010-479f2141a98a

Thanks for your support!

icon

Best answer by david_r 18 June 2018, 10:00

View original

3 replies

Userlevel 5

Assuming that you're looking for the string that succeeds any GUID, you could use the following expression in e.g. an AttributeCreator:

@Substring(@Value(text_line_data),@FindRegEx(@Value(text_line_data),"\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1}")+37)
Userlevel 5
Badge +26

If you split using the | as a delimiter character and then use a StringReplacer to chop off the 62b88ad3-1c54-43b2-b010-479f2141a98a bit from the correct part. I'm assuming it's different for every feature but will always have that structure.

^\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}[ ] as a regex would do the trick

screen-shot-2018-06-18-at-100052none2none.fmw

Hope this helps.

Userlevel 3
Badge +17
Is the entire "62b88ad3-1c54-43b2-b010-479f2141a98a" a delimiter string given through an attribute?

 

If so, is this your desired result from the example?

 

  • _list{0} has '2018-06-11 08:39:23| 486.7| 0.0|STATS |'
  • _list{1) has '' (empty)

 

Reply