Re: Simple regex
by g0n (Priest) on Jan 19, 2005 at 12:20 UTC
|
What do you mean by 'exactly the contrary'? | [reply] |
Re: Simple regex
by gellyfish (Monsignor) on Jan 19, 2005 at 12:21 UTC
|
| [reply] [d/l] [select] |
Re: Simple regex
by Dietz (Curate) on Jan 19, 2005 at 12:55 UTC
|
Maybe this is what you're looking for:
$text =~ s/(.+\s)\S*\.\S*/$1/g;
OUTPUT:
0000 636d6400 5589e583 ec0831c0 83e4f0e8
0010 00000000 e8000000 0083ec0c 68000000
0020 00e80000 000031c0 c9c39090 90909090
| [reply] [d/l] [select] |
|
|
thanks for your help but the problem is still there.
this is my source code :
#!perl -w
#
use strict;
#
# Hashes
my %struct_compilation = (
"objdump" => "%s -j .text -s -z %s",
);
my %compilation = (
"objdump" => "",
);
my %return = (
"objdump" => "",
);
my $path = "D:/Progs/Programmation/Dev-Cpp/bin/";
my %compiler = (
"objdump" => $path . "objdump.exe",
);
#
# Main
if( @ARGV < 1 )
{
exit( 0 );
}
my $src = $ARGV[0];
$compilation{"objdump"} = sprintf( $struct_compilation{"objdump"}, $co
+mpiler{"objdump"}, $src );
$return{"objdump"} = `$compilation{"objdump"}`;
$return{"objdump"} =~ s/[0-9a-f]{4}//g ;
print $return{"objdump"};
i want to print the hexa decimal string whitch is returned by objdump but my regex do the contrary ! | [reply] [d/l] |
|
|
$return{"objdump"} =~ s/[0-9a-f]{4}//g;
with
$return{"objdump"} = join("",$return{"objdump"} =~ /[0-9a-f]{4}/g)
| [reply] [d/l] [select] |
|
|
|
|
| [reply] |
Re: Simple regex
by Random_Walk (Prior) on Jan 19, 2005 at 13:47 UTC
|
the {4} in your regex makes me think perhaps you wanted something like this to strip out the leading blocks of four which I assume go hex.
$text=~s/(^|\n)[0-9a-f]{4} /\1/g
# gives
636d6400 5589e583 ec0831c0 83e4f0e8 cmd.U.....1.....
00000000 e8000000 0083ec0c 68000000 ............h...
00e80000 000031c0 c9c39090 90909090 ......1.........
Cheers, R.
Pereant, qui ante nos nostra dixerunt!
| [reply] [d/l] |
Re: Simple regex
by Isothop (Acolyte) on Jan 19, 2005 at 13:51 UTC
|
cls.c.o: file format pe-i386
Contents of section .text:
0000 636d6400 5589e583 ec0831c0 83e4f0e8 cmd.U.....1.....
0010 00000000 e8000000 0083ec0c 68000000 ............h...
0020 00e80000 000031c0 c9c39090 90909090 ......1.........
what i want the reget to output :
0000636d64005589e583ec0831c083e4f0e8001000000000e80000000083ec0c680000
+00002000e80000000031c0c9c3909090909090
| [reply] [d/l] [select] |
|
|
| [reply] [d/l] |
|
|
| [reply] |
Re: Simple regex
by Isothop (Acolyte) on Jan 19, 2005 at 17:24 UTC
|
this is the code which i use finally. it works. thanks you guys :)
$return{"objdump"} = join( "", $return{"objdump"} =~ /[0-9a-f]{8}/g );
my $length = length $return{"objdump"};
for( my $i = 0 ; $i < $length ; $i += 2 )
{
print "\\x" . substr( $return{"objdump"}, $i, 2 );
}
| [reply] [d/l] |
|
|
Here's another way to do the same thing:
$return{"objdump"} =~ s/.*?([0-9a-f]{8}|$)/$1/gs;
print "\\x$_" for $return{"objdump"} =~ /../g;
The first line strips out every string preceding an eight-digit hex number or end of string. The second line splits the string into two-digit substrings and prints them.
Caution: Contents may have been coded under pressure.
| [reply] [d/l] |