Solved

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

  • 18 April 2022
  • 2 replies
  • 18 views

Badge +6

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

icon

Best answer by dustin 18 April 2022, 22:46

View original

2 replies

Userlevel 3
Badge +26

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

 

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

Badge +6

Woohoo! Thank you!

Reply