regex - Python: hexadecimal regular expression question -


I want to parse the output of a serial monitoring program called doclight (I highly recommend this) This 'hexadecimal' string Does output: or a sequence (two capital hex points after a space) This is the regular expression: ([0- 9A-F] {2}) + For example: '05 03 dA 4 B3F '

< P> When the program detects specific sequences of characters, it gives comments in the 'hexadecimal' string. For example:

  '05 03 04 01 A Header 03 08 B BD Air Force Payment 0 D Footer ' 

The format is '. + ' (one sequence of characters before a space and after one place)

I have to get rid of the comments. For example, the 'hexadecimal' string above the filter will be:

  '05 03 04 01 A 03 08 B.BDFDDA ' 
< P> How do I do this with a regular expression?

You can try:

  & gt; & Gt; & Gt; A = '05 03 04 01 A Header 03 08 B BD Air Force PAD 0A Powder '& gt; & Gt; & Gt; ('05', '03', '04', '01', '0A', '03' '' B [0- 9A-F] {2} In regular expressions,  \ b  one matches the "word boundary". 

Of course, your input is unclear if the serial monitor is something this BE THE HEADER .

< / Div>

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -