Find Hex number

0 views
Skip to first unread message

Hashmat

unread,
Nov 7, 2009, 12:55:09 PM11/7/09
to Regex
Hello,

Suppose I have this hex input: "78FE8909CD" etc

Can somebody please let me know what should be the RE to find a
particular byte ?

Say I want to find 8F from the above input ?
RE should return false, because 8F is not found as a byte because the
bytes would be:7F, FE, 89, etc

Is is possible to find this using RE ?

thanks
Hashmat

inhahe

unread,
Nov 8, 2009, 2:40:53 AM11/8/09
to re...@googlegroups.com
hmm, maybe this

.{2]*?8F.*

Ashmath Khan

unread,
Nov 8, 2009, 5:59:41 AM11/8/09
to re...@googlegroups.com
Thanks.
How do I find if a particular character is not present in a string ?
If I use [^0x1f] it would mean any character other than 1f. How do write a RE which would mean if 1f is not present ? In other words if the patter 1f is not matched.

thanks
Ashmath

Затлер Евгений Викторович

unread,
Nov 10, 2009, 5:07:30 AM11/10/09
to re...@googlegroups.com
On Sun, Nov 8, 2009 at 11:40 AM, inhahe <inh...@gmail.com> wrote:
> hmm, maybe this
> .{2]*?8F.*
1) closing bracket incorrect. should be }

2) .{2,} construct allows any symbol to be repeated 3 times or 5
times, i.e. uneven number of times. This should be forbidden in this
case.

So, I suggest

^([0-9a-z][0-9a-z])*8F([0-9a-z][0-9a-z])*$

--
regards, Eugeny

Eugeny Sattler

unread,
Nov 10, 2009, 5:31:02 AM11/10/09
to re...@googlegroups.com
> How do I find if a particular character is not present in a string ?
> If I use [^0x1f] it would mean any character other than 1f.

Nope. [^0x1f] will be treated as any symbol which is not a zero, not a
literal "x", not 1 and not "f"

[^\x1F] is the right syntax for what you meant.


> How do write a RE which would mean if 1f is not present ? In other words if the patter 1f
> is not matched.
>

1st approach
Check if 1F is present. And if it is present do nothing. Else do what you need.

2nd approach:
^[^\x1F]*$
will match a set of symbols each and every of them is not 1F


--
best regards, Eugeny

Reply all
Reply to author
Forward
0 new messages