Please help me with extracting Values between brackets and form an output String.
Sample: Aspirin (150mg) + Atorvastatin (10mg) + Clopidogrel (75mg) Capsule
Desired Output : 150mg + 10mg + 75mg
Thank You
Please help me with extracting Values between brackets and form an output String.
Sample: Aspirin (150mg) + Atorvastatin (10mg) + Clopidogrel (75mg) Capsule
Desired Output : 150mg + 10mg + 75mg
Thank You
On
Here's an alternative if you have access to TEXTJOIN formula. You need to enter it using Ctrl+Shift+Enter (convert it to an array):
=TEXTJOIN("mg + ",TRUE,IFERROR(TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"(",REPT(" ",255)),"mg)",REPT(" ",255)),1+255*ROW($A$1:INDEX($A:$A,LEN(A1))),255))*1,""))&"mg"
The result:
On
Another option to use TEXTJOIN function, and together with the INDEX+FILTERXML to force the array formula into a shorter and normal formula,
and the FILTERXML function return an array without error/blank cells, so the IFERROR() is not necessary
Then in B2, formula copied down :
=TEXTJOIN("+",1,INDEX(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,")",""),"(","<r/>")," ","</b><b>")&"</b></a>","//b[r]"),0))
You can try below formula but it is based on your example. Need to adjust
Num_Charsparameter if data length inparenthesesare different.