Skip to main content

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.

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

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


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.


Thanks for you answers, It worked.

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


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.

 


@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