Skip to main content
Solved

How to take a string (RegEx) within a current attribute and make a new field with it?


juliarozema
Contributor
Forum|alt.badge.img+7

I have a string in a attribute. At the end of the string there are brackets containing one or more words. I would like the contents, including the brackets to be put into a new attribute.

 

Ex:

Attribute = "cat mouse (cheese crackers)"

Desired new attribute = "(cheese crackers)"

NOTE: sometimes there is one, two or more words with in the brackets, and I want all of them in the new field.

 

Using a RegEx (\\(([\\w]+( [\\w]*)*)\\)$) I can select that portion of the string, but I don't know how to put that portion into a new attribute.

 

Currently I have an AttributeCreator

with Attribute Value = @FindRegEx(@Value(Attribute),"\\(([\\w]+( [\\w]*)*)\\)$")

but the result is not the string, but numbers.

 

Thank you in advance for your time.

Julia

Best answer by dustin

I would use the StringSearcher with regex \\(.+\\)

 

You can then specify the output attribute, or leave as _first_match.

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

2 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • April 18, 2022

I would use the StringSearcher with regex \\(.+\\)

 

You can then specify the output attribute, or leave as _first_match.


juliarozema
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • April 18, 2022

Woohoo! Thank you!


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