Search regular expression with search for hex values in files?

P

Peter Hanke

For a given file aaa.txt I want to check wether it contains a hex value e.g. x'77' (=1 byte)
BUT not a hex sequence x'8877' (=two bytes). In other words byte value x'77' should exist
but it must not NOT be preceded by byte value x'88'.

How can I specify this (pre-)conditions in ONE regular expression and pass it e.g. to grep?

Peter
 
D

Dr.Ruud

Peter Hanke schreef:
For a given file aaa.txt I want to check wether it contains a hex
value e.g. x'77' (=1 byte) BUT not a hex sequence x'8877' (=two
bytes). In other words byte value x'77' should exist but it must not
NOT be preceded by byte value x'88'.

How can I specify this (pre-)conditions in ONE regular expression and
pass it e.g. to grep?

Where you say 'hex value' I assume you just mean 'character value'
(conveniently presented in hexadecimal format).

m/(?<!\x88)\x77/

See `perldoc perlre`, look for "look-behind assertion".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top