perl - Why does adding a character class to the end of a regex fail to match hex numbers? -


perl accepts:

my @resultado = $texto =~ /[^g-zg-z]$re{num}{real}{-base=>16}/g 

but doesn't accept:

my @resultado = $texto =~ /[^g-zg-z]$re{num}{real}{-base=>16}[^g-zg-z]/g 

i add [^g-zg-z] @ end; @ beginning works not @ end. why? want print hexadecimal numbers but, example, in cases there word 'call' should not 'ca' hexadecimal number.

the character class [^g-zg-z] matches single character not in range g through z. not want matching hexadecimal digit. example, if hex number occurs @ end of string (that is, nothing follows it), match fail.

you did not provide sample data. pattern such as

my @resultado = $texto =~ /\b([0-9a-fa-f]+)\b/g; 

may give want. \b matches @ word boundary, , constrains hex digits occur within single “word.”

in regexp::common terms, above line expressed as

my @resultado = $texto =~ /\b($re{num}{int}{-base => 16})\b/g; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -