Parsing sting data

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

Guest

Hello all,

I have a string of data that I need to parse once I move over 181. This is
not lines, but character spaces. What is the command or procedure to count
char spaces?

Thanks
 
Well I found it, or at least a way to do it. I'm using the Left(string,181).

I have another question now. How do I know when I have reached the end of
the string? I would use the EOF and loop if this were records in a file, but
this being a string that varies how do I know when I reached the end?

Thanks
 
Are you perhaps looking for the Len function? It'll tell you how many
characters are in a string.
 
Well I found it, or at least a way to do it. I'm using the Left(string,181).

I have another question now. How do I know when I have reached the end of
the string? I would use the EOF and loop if this were records in a file, but
this being a string that varies how do I know when I reached the end?

Thanks

Len(VariableName) will tell you how many characters there are in the
string.
 
I am getting string data from a UNIX box. The string could contain hundreds
of records. I need to read through it and after going 181 char then use the
“& CrLf†to start a new line. Once I read through it all I will create a
text file. Would this be the way to use that Len fuction to get the result I
am trying to get?

vLen = len(mystring)

vResults = vResults + left(myString, 181)

vCnt = vCnt + 181

if vCnt = vLen then

end


I see another issue too now that I look at this. If I use the “181†and
left function then it will always read the first record. How would I read a
string and get the first record (181 length) then move on over to the Second
record (starting at 182 end at 363)?

Thanks!
 
It might be simpler to fix the data at the Unix end. Filtering it
through this will insert a Windows-style line break after each 181
characters:

perl -wpe"chomp; s/(.{181})/$1\x0d\x0a/g"
 
Back
Top