Skip to main content
Solved

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

  • April 18, 2022
  • 2 replies
  • 178 views

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.

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.

2 replies

dustin
Influencer
Forum|alt.badge.img+31
  • Influencer
  • 627 replies
  • 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
  • 44 replies
  • April 18, 2022

Woohoo! Thank you!