Split or Trim Function

# Thread: Split or Trim Function

1. Member
Join Date
Dec 1969
Posts
83

## Split or Trim Function

Hi there,<BR><BR>I have a string with sections divided by commas, but the section is sub-divided with text inside of parens. i.e.:<BR><BR>text(text), text(text), etc.<BR><BR>Is there a way to parse out the text in the parens for each section using the split function?<BR><BR>Thanks.<BR>

2. Member
Join Date
Dec 1969
Posts
46

## RE: Split or Trim Function

Use Split(string,",")

3. Member
Join Date
Dec 1969
Posts
83

## RE: Split or Trim Function

Thanks for the reply, but could you please offer a little more info? Thanks.<BR>

4. aspa Guest

## RE: Split or Trim Function

try like this.am not sure.might get some idea.<BR><BR>x="ar(name),pr(post)"<BR>x2=split(x," (",-1,1)

5. Eddie Campbell Guest

## RE: Split or Trim Function

I don&#039;t think you can do it just with split. You would need to do something like this:<BR><BR>&#060;%<BR>MyStr="Text1(Hello),Text2( GoodBye)"<BR>MyArray = Split(MyStr,",")<BR>For I = 0 to Ubound(MyArray)<BR> MainStr = Left(MyArray(I),Instr(MyArray(I),"(")-1)<BR> SubStr = Mid(MyArray(I), Instr(MyArray(I),"(")+1 , Len(MyArray(I)) - Len(MainStr) -2)<BR> Response.Write MainStr & "<BR>"<BR> Response.Write SubStr & "<BR>"<BR>Next<BR>%&#062;<BR>

6. aspa Guest

## RE: Split or Trim Function

x="ar(name),pr(post)"<BR>x2=split(x,"(",-1,1)<BR>&#039;Response.Write x2(1) & "<BR>"<BR>x3=split(x2(2),")")<BR>Response.Writ e x3(0)<BR><BR>be changing the index values.you will get it.

7. Eddie Campbell Guest

## RE: Split or Trim Function

Nice splitting work there!<BR><BR>The only problem I can see is that if Debbie wants to get BOTH the main string, and the substring, your way wouldn&#039;t work.<BR><BR>But then again maybe she doesn&#039;t want that :)

8. Member
Join Date
Dec 1969
Posts
83

## RE: Split or Trim Function

Thanks, Eddie, it worked like a champ!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•