regex - hex class

Discussion in 'Perl Misc' started by John, Oct 7, 2009.

  1. John

    John Guest

    Hi

    I may have an error elsewhere in my program,
    but , for the moment, will the following removed all hex chars 00 to 40?

    $x =~ s|[\x00-\x40]||g;

    Regards
    John
    John, Oct 7, 2009
    #1
    1. Advertising

  2. John

    Guest

    On Wed, 7 Oct 2009 14:38:09 +0100, "John" <> wrote:

    >Hi
    >
    >I may have an error elsewhere in my program,
    >but , for the moment, will the following removed all hex chars 00 to 40?
    >
    >$x =~ s|[\x00-\x40]||g;
    >
    >Regards
    >John
    >
    >

    "but , for the moment, will the following removed chars: hex 00 to 40?
    That should work, have you tried it?
    $x =~ s/[\x{00}-\x{40}]//g;

    -sln
    , Oct 7, 2009
    #2
    1. Advertising

  3. John

    John Guest

    <> wrote in message
    news:...
    > On Wed, 7 Oct 2009 14:38:09 +0100, "John" <> wrote:
    >
    >>Hi
    >>
    >>I may have an error elsewhere in my program,
    >>but , for the moment, will the following removed all hex chars 00 to 40?
    >>
    >>$x =~ s|[\x00-\x40]||g;
    >>
    >>Regards
    >>John
    >>
    >>

    > "but , for the moment, will the following removed chars: hex 00 to 40?
    > That should work, have you tried it?
    > $x =~ s/[\x{00}-\x{40}]//g;
    >
    > -sln


    Hi

    It doesn't work so I now know I have a problem somewhere else.

    Regards and thanks
    John
    John, Oct 7, 2009
    #3
  4. John wrote:
    >
    > I may have an error elsewhere in my program,
    > but , for the moment, will the following removed all hex chars 00 to 40?
    >
    > $x =~ s|[\x00-\x40]||g;


    $ perl -le'
    use Data::Dumper;
    $Data::Dumper::Useqq = 1;
    my $string = join q//, map chr, 0 .. 127;
    print Dumper $string;
    $string =~ s|[\x00-\x40]||g;
    print Dumper $string;
    '
    $VAR1 =
    "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37
    !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";

    $VAR1 =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";


    Yes, that works.



    John
    --
    The programmer is fighting against the two most
    destructive forces in the universe: entropy and
    human stupidity. -- Damian Conway
    John W. Krahn, Oct 7, 2009
    #4
  5. John

    John Guest

    "John W. Krahn" <> wrote in message
    news:iE7zm.225471$...
    > John wrote:
    >>
    >> I may have an error elsewhere in my program,
    >> but , for the moment, will the following removed all hex chars 00 to 40?
    >>
    >> $x =~ s|[\x00-\x40]||g;

    >
    > $ perl -le'
    > use Data::Dumper;
    > $Data::Dumper::Useqq = 1;
    > my $string = join q//, map chr, 0 .. 127;
    > print Dumper $string;
    > $string =~ s|[\x00-\x40]||g;
    > print Dumper $string;
    > '
    > $VAR1 =
    > "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37
    > !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";
    >
    > $VAR1 =
    > "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";
    >
    >
    > Yes, that works.
    >
    >
    >
    > John
    > --
    > The programmer is fighting against the two most
    > destructive forces in the universe: entropy and
    > human stupidity. -- Damian Conway



    OK. Thanks. It should removed '0A' and I guess it does but it re-appears
    later on.
    My guess is somewhere later in the propram it is added back.

    Regards
    John
    John, Oct 8, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    6,133
    Neredbojias
    Aug 19, 2005
  2. Bengt Richter
    Replies:
    6
    Views:
    448
    Juha Autero
    Aug 19, 2003
  3. jack
    Replies:
    4
    Views:
    574
  4. tim

    hex string to hex value

    tim, Nov 22, 2005, in forum: Python
    Replies:
    8
    Views:
    18,794
  5. tim
    Replies:
    2
    Views:
    1,538
    Dennis Lee Bieber
    Nov 23, 2005
Loading...

Share This Page