i use a string str1= { 0xFEFE 0x0111 0x00 }, { 0xFEFE 0x0112 0x01 }, { 0xFEFE 0x0113 0x01 },{ 0xFEFE 0x0114 0x00 }
need to find and seperate the substrings that end with 0x00 in one list and the substrings that end with 0x01 in another list.
could anyone please help me to write a python script.

Use re.findall()

that doesn't work..can u provide me a solution without using the default function

lst = re.findall(r"0xFEFE.*0x01 }",str1)
print(lst) 

output:

['0xFEFE 0x0111 0x00 }, { 0xFEFE 0x0112 0x01 }, { 0xFEFE 0x0113 0x01 }']

lst = re.findall(r"0xFEFE.*0x00 }",str1)
print(lst) 

ouput:

['0xFEFE 0x0111 0x00 }, { 0xFEFE 0x0112 0x01 }, { 0xFEFE 0x0113 0x01 }, { 0xFEFE 0x0114 0x00 }']

this is the result iam getting...please somebody could correct this

I used this

lst = re.findall(r"{\s[^}]*0x01\s}",str1)

and it worked.

its working..thanks..

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.