hi...

I have a value, value=4501-E001

I am concerned about only the value before hyphen i.e., 4501

I need to check whether various values begin with 4501, followed by something, n am not concerned about "something" that follows.

How can this splitting be done in python?

Don't need to .split('-') but you can check directly begining by startswith.

Don't need to .split('-') but you can check directly begining by startswith.

thanx for the reply...but the value is an octet string, n when i tried startswith, it said octetstring has no attribute startswith

thanx for the reply...but the value is an octet string, n when i tried startswith, it said octetstring has no attribute startswith

yes...i got a simple solution..

here s it, hoping it might help some newbie like me:)

if value[:4]== '4501':
print "xxx..whatever..."

octet-string?? Give running code I never heard such a thing? It has not string representation for str function?

if str(value).startswith(start):

yes...i got a simple solution..

here s it, hoping it might help some newbie like me:)

if value[:4]== '4501':
print "xxx..whatever..."

What you can do with an object depends entirely on its class. I suspect that your object's class is pyasn1.type.univ.OctetString. You should probably be able to convert the value to a python string by using mystring = str(value) .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.