Search for Text within Text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
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),"(",""),")","")
 
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),"(",""),")","")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top