Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Regex grouping without storingby gmoque (Acolyte) |
on Oct 06, 2011 at 17:11 UTC ( [id://930023]=perlquestion: print w/replies, xml ) | Need Help?? |
gmoque has asked for the wisdom of the Perl Monks concerning the following question: Mongers, I want to take data from two different inputs and then I want to apply a common regex to extract hex digits from it; the problem is that one device spits the hex values as 0x and the other data doesn't use the 0x, which makes my regex looks a bit ugly My idea is to have something like this:
This is what the two different commands output looks like
The main issue I have is the 0?x? format in the $addr scalar looks horrible, so I was thinking to use grouping like (0x)? but the problem is this will break the substitution so I am wondering if there another way to write (0x)? without storing the data in $1 Thanks for your wisdom
Back to
Seekers of Perl Wisdom
|
|