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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing text 1

Status
Not open for further replies.

Perilous1

IS-IT--Management
Mar 10, 2005
171
US
If I have a string that looks like:

Phoenician,EP/S,,Phoenix,,,8/27/2009

What would be the simplest method to isolate out the relevant data between the commas that separate them?
 



Hi,
Code:
dim a, s as string, i as integer
s = "Phoenician,EP/S,,Phoenix,,,8/27/2009"
a = split(s, ",")

for i = 0 to ubound(a)
  msgbox a(i)
Next

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
That sort of works. The problem is that one blank Msgbox pops up accounting for the second comma in the double comma and two pop up accounting for the second & third comma in the triple comma.

I can still work with this by ignoring any strings of (If a(i) = "") but it's not quite as neat.

Worthy of a Star though. Thanks!
 
Code:
dim a, s as string, i as integer
s = "Phoenician,EP/S,,Phoenix,,,8/27/2009"
[COLOR=blue]Do While InStr(s, ",,") > 0
   s = Replace(s, ",,", ",")
Loop[/color]

a = split(s, ",")

for i = 0 to ubound(a)
  msgbox a(i)
Next

;-)
 



Quite often, when parsing, 'empty' positions are significant. You didn't ask. But thanx anyhow.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top