Skip to main content
Solved

Exctract values from a string (attribute value) ?


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.

View original
Did this help you find an answer to your question?

5 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • 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
Evangelist
  • 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+17
  • Contributor
  • November 22, 2016
erik_jan wrote:

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
erik_jan wrote:
@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.

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings