tomt
07-14-2010, 07:06 PM
Hello all,
I'm tying to parse a sting into three smaller strings. I do this in three steps, but after the last step all three strings are equal to the last string. heres my function
def LinkAckWithName(data):
print data
# Parse Senders Address
index = 0
while data[index] != '{':
index = index + 1
if index > 10:
break
SendersAddress = data[index+1:index+7]
# Parse DataType
index = 0
while data[index] != '[':
index = index + 1
if index > 20:
break
DataType = data[index+1:index+4]
# Parse Name
index = 0
while data[index] != '<':
index = index + 1
if index > 30:
break
Name = data[index+1:index+11]
print SendersAddress
print DataType
print Name
for the Input string "{123456}[001]<abcdefjhij>". I get
abcdefjhij
abcdefjhij
abcdefjhij
instead of
123456
001
abcdefjhij
I know that each individual section works, because I tried printing the result after each section.
I know that SNAPpy has some limitations when it comes to string manipulation, but I'm sure there must be a way to do this.
Thanks,
I'm tying to parse a sting into three smaller strings. I do this in three steps, but after the last step all three strings are equal to the last string. heres my function
def LinkAckWithName(data):
print data
# Parse Senders Address
index = 0
while data[index] != '{':
index = index + 1
if index > 10:
break
SendersAddress = data[index+1:index+7]
# Parse DataType
index = 0
while data[index] != '[':
index = index + 1
if index > 20:
break
DataType = data[index+1:index+4]
# Parse Name
index = 0
while data[index] != '<':
index = index + 1
if index > 30:
break
Name = data[index+1:index+11]
print SendersAddress
print DataType
print Name
for the Input string "{123456}[001]<abcdefjhij>". I get
abcdefjhij
abcdefjhij
abcdefjhij
instead of
123456
001
abcdefjhij
I know that each individual section works, because I tried printing the result after each section.
I know that SNAPpy has some limitations when it comes to string manipulation, but I'm sure there must be a way to do this.
Thanks,