Me again

1. Senior Member
Join Date
Dec 1969
Posts
240

## Me again

I have two strings that I make and pass to another asp page. One is strA_strB, the other is strA-strB.<BR><BR>How can I find out if string a is seperated from string b by an underscore (_) or a minus sign? (-)

2. LeeAnnie Guest

## RE: Me again

What you could do is use the Instr() function:<BR><BR>strSomeString = "This is a string with a - in it."<BR>strAnotherString = "This is a string with an under_score in it."<BR><BR>Instr(strSomeString, "-") &#039would return a value of 1<BR>Instr(strSomeString, "_") &#039would return a value of 0<BR>Instr(strAnotherString, "-") &#039would return a value of 0... and so on<BR><BR>&#039therefore<BR>if (Instr(strSomeString, "-") &#062; 0) then<BR> response.write ("strSomeString had a hyphen in it")<BR>end if<BR><BR>Hope this helps:)<BR>

3. LeeAnnie Guest

## Need to edit my reply

The number Instr() returns would be the character position on the hyphen<BR>... so the number returned for the first example would be something like 15 (too lazy to count)

4. Senior Member
Join Date
Dec 1969
Posts
240

## Thanks! One more!

That worked out well. I have one more question. How would I break up a string like this?<BR><BR>ABC.DEF.GHI<BR><BR>So that strOne = ABC<BR>strTwo = DEF<BR>strThree = GHI<BR><BR>Thanks everyone who has helped!

5. Senior Member
Join Date
Dec 1969
Posts
240

## RE: Need to edit my reply

That is ok. I got your meaning.

6. LeeAnnie Guest

## split() function!

Use the split() function<BR><BR>split(strTwo,".")<BR><BR>Here is an example of some code that splits a string of e-mail addresses that are separated by commas:<BR><BR>for each t_email in split(request("NOTIFY"),",")<BR> if instr(t_email,"@")&#060;2 or instrrev(t_email,".")&#060;4 or instr(t_email,"@")&#062;instrrev(t_email,".") then<BR> t_err=t_err&"D"<BR> end if<BR>next<BR><BR>Good luck

#### Posting Permissions

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