(Td-234) this is the text we keep (dont need to remove)
(Ta-546) hello (ba vg) in this cass
so in the example above of two strings trying to remove both first parentheses and its text. I have used regex replace but it removes all parthesis while i want to remove only first one and its text. Please help
Can you provide more sample data and expand on your ask? Quite confused, and I’m not clear exactly what you want.
So for example please find it below:
This is how the field looks like
(TD-123) General Marchandise - store (rev c)
(TD-135) General Marchandise - store (rev c) marchandise - night version
So in this case what i need to is get rid if (TD-123) in first row and (TD-135), So the ask is remove the parthesis and data within.
jdminton - If i need to adjust can you please guide me how to adjust to remove second () as i am new to alteryx still learning these adhoc formulas.
Based on your example, it should work, but please post back if any issues.
Thanks i now need to remove first bracket and keep the second one. Thanks
@georgehenry you didn't provide an example, but you would replace my formula where it is ")" with "]" if that is the type of bracket you are referring to.
For the RegEx provided by @danilang , you would use regex_replace([Field1],"^\[.*?\]\s(.*)","$1")
@georgehenry @danilang's excellent answer assumes that the first parentheses is always at the beginning of the line. If it's possible for the parentheses to occur in other places in the strings then a more complex formula might be needed. (if not then obvs use the above solution).
If that is the case try this approach:
IF CONTAINS([Input],'(')
AND CONTAINS([Input],')')
THEN
REGEX_Replace([Input], '(^[^\(\)]*)\(.+?\) ?(.*)','$1$2')
ELSE [Input]
ENDIF
Here I capture all the non parentheses at the beginning of the string, and then capture everything after the first set of parentheses, and concatenate these together (ignoring the space after the parentheses if it's there).