Search for Text within Text

S

Samantha

Hi,
I need to search for strings of text within a text.
The format of the text is: "(abc)+(efg)"
What I need is to parse out the string within the parenthese only:
Text1 = "abc"
Text2 = "efg"

How can I do that? I've looked up the InStr function but not exactly sure
what else I need. Can someome help me? Thanks in advance.
 
A

Albert D. Kallal

Samantha said:
Hi,
I need to search for strings of text within a text.
The format of the text is: "(abc)+(efg)"
What I need is to parse out the string within the parenthese only:
Text1 = "abc"
Text2 = "efg"

How can I do that? I've looked up the InStr function but not exactly sure
what else I need. Can someome help me? Thanks in advance.

Are they *always* 3 characters in lenght?

Lets assume they are not:
try:
From the debugger I get:

? split(split("(abc)+(efg)","(")(1),")")(0)
abc

? split(split("(abc)+(efg)","(")(2),")")(0)
efg


so:

text1 = split(split([MyTextField],"(")(1),")")(0)

text2 = split(split([MyTextField],"(")(2),")")(0)


If they are *always* each 3 characters, then the solution is easy...use mid:

text1 = mid([MyTextField],2,3)

text2 = mid([MyTextField],8,3)
 
F

fredg

Hi,
I need to search for strings of text within a text.
The format of the text is: "(abc)+(efg)"
What I need is to parse out the string within the parenthese only:
Text1 = "abc"
Text2 = "efg"

How can I do that? I've looked up the InStr function but not exactly sure
what else I need. Can someome help me? Thanks in advance.

Text1 =
Replace(Replace(Left([CombinedText],InStr([CombinedText],"+")-2),"(",""),")","")

Text2 =
Replace(Replace(Right([CombinedText],Len([CombinedText])-InStr([CombinedText],"+")-1),"(",""),")","")
 
S

Samantha

Although I have not figured out how they work yet, but Both methods work!
Thank you so much Albert and fredg!

fredg said:
Hi,
I need to search for strings of text within a text.
The format of the text is: "(abc)+(efg)"
What I need is to parse out the string within the parenthese only:
Text1 = "abc"
Text2 = "efg"

How can I do that? I've looked up the InStr function but not exactly sure
what else I need. Can someome help me? Thanks in advance.

Text1 =
Replace(Replace(Left([CombinedText],InStr([CombinedText],"+")-2),"(",""),")","")

Text2 =
Replace(Replace(Right([CombinedText],Len([CombinedText])-InStr([CombinedText],"+")-1),"(",""),")","")
 
Top