Skip to main content
Solved

Split text attribute based on attribute value

  • June 18, 2018
  • 3 replies
  • 69 views

whkarto
Contributor
Forum|alt.badge.img+14

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!

Best answer by david_r

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)
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

david_r
Celebrity
  • 8394 replies
  • Best Answer
  • June 18, 2018

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)

redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3703 replies
  • June 18, 2018

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.


takashi
Celebrity
  • 7843 replies
  • June 18, 2018
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)