Skip to main content
Solved

Exctract values from a string (attribute value) ?

  • November 22, 2016
  • 5 replies
  • 28 views

Forum|alt.badge.img

Hi,

I have strings (ex New York : Ballantine Books, c2003, 2006.) what I'm interested to do is to get the year(s) out of that string to populate an other attribute.

In short, getting 2003 and 2006 in a different field. As dates are not always the same, regex would be best.

Is it possible? If so, could someone explain to me how ? Please.

Thanks.

Best answer by david_r

You can use the StringSearcher, e.g.:

0684Q00000ArKfpQAF.png

This matches all groups of four digits in your string.

The years will exit in the list _all_years{}, e.g.

Attribute(encoded: utf-8)         : `_all_years{0}.match' has value `2003'
Attribute(encoded: utf-8)         : `_all_years{0}.startIndex' has value `19'
Attribute(encoded: utf-8)         : `_all_years{1}.match' has value `2006'
Attribute(encoded: utf-8)         : `_all_years{1}.startIndex' has value `25'

You can e.g. use a ListExploder after, if needed.

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.

5 replies

erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • November 22, 2016

I would use the StringSearcher with a regex "\\d* ,\\d*$".

Follow by an AttributeSplitter (delimiter comma) or two SubStringExtractors.


david_r
Celebrity
  • Best Answer
  • November 22, 2016

You can use the StringSearcher, e.g.:

0684Q00000ArKfpQAF.png

This matches all groups of four digits in your string.

The years will exit in the list _all_years{}, e.g.

Attribute(encoded: utf-8)         : `_all_years{0}.match' has value `2003'
Attribute(encoded: utf-8)         : `_all_years{0}.startIndex' has value `19'
Attribute(encoded: utf-8)         : `_all_years{1}.match' has value `2006'
Attribute(encoded: utf-8)         : `_all_years{1}.startIndex' has value `25'

You can e.g. use a ListExploder after, if needed.


Forum|alt.badge.img
  • Author
  • November 22, 2016

Thanks for you answers, It worked.

I'll have to remember that All Matches List Name is putting match in a list.


erik_jan
Contributor
Forum|alt.badge.img+23
  • Contributor
  • November 22, 2016

I would use the StringSearcher with a regex "\\d* ,\\d*$".

Follow by an AttributeSplitter (delimiter comma) or two SubStringExtractors.

@jacob1 Down voting an effort to try and help you is not the best way of showing appreciation.

 


Forum|alt.badge.img
  • Author
  • November 22, 2016
@jacob1 Down voting an effort to try and help you is not the best way of showing appreciation.

 

Sorry, for the -1... it is an accident... not knowing how it works.

 

I'll pay attention next time.

 

 

Thanks to have answered my question.

 

 

Jacob1.