Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read string 3

Status
Not open for further replies.

Footbal76

MIS
Sep 6, 2006
21
US
I have this string of text. Within the string there is a space. And then it proceeds with the string.

I would like to parse the string out every 3 characters after the SPACE in its separate string

So example if sparsed out every 3 characters it would look like this

ART 1string
ASC 2string
BIO 3string
HUM 4string
JUR 5string
MPS 6string
ect:

here is the string
RSAP5RSCH8RSDB1RSID1RSIV6RSLG9RSUM1RUWE1 ARTASCBIOHUMJURMPSMUSSBSUSSUVC
 
>I need to put each one of these ART, ASC, BIO, HUM, JUR, MPS, MUS, SBS, USS, UVC

Like this after the colMatch is established.
[tt]
dim a()
redim a(colMatch.count-1)
for i=0 to colMatch.count-1
a(i)=colMatch(i)
next
response.write join(a,", ") & "<br />"
[/tt]
 
Amendment
By colMatch, I meant MatchCol per onpnt notation.
 
I have it workin now
my string had balnk spaces in them like 2 hundred spaces
I just used the (ltrim) method and it worked
Thanks to u all
 
To answer the "If you do not know the numeric length value" question I would just pass that value to the function and build the pattern.

example with the given replies above worked in

Code:
totalcolls  = "ARTASCBIOHUMJURMPSMUSSBSUSSUVC"


Function ExCol(num)
	Set regex = New RegExp

	With regex
	.Pattern = "[a-zA-Z]{" & num & "}"
	.IgnoreCase = False
	.Global = True
	End With

	Set matchCol = regex.Execute(totalcolls )

	If matchCol.Count > 0 Then
	dim a()
	redim a(matchCol.count-1)
	for i=0 to matchCol.count-1
		a(i)=matchCol(i)
	next
	response.write join(a,", ") & "<br />"
	End If
End Function

ExCol 3

General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
star to Scheco and tsuji for the good tips and keeping it going after I went missing after changing the direction of the thread :)

Scheco has a bunch of knwoledge in the first few posts you should pay close attention to and what the functions are doing. They are meant for this type of task. and again you can see the join() tsuji used which is also something you should read up on. A little reading of string manipulation and such gets you a long way prior to diving into something like this even if it is a form of beginning steps.

Have a good weekend all!!!

General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top