in reply to striping nulls
Here's a demonstration to show how a regex substitution should work to remove null bytes:
You can also use the "tr///" operator:s/\x00+//g;
To see that in action, consider the following command lines, using perl one-liners (and assuming you have the "xxd" utility for doing a hex dump of stdin -- or some equivalent tool):tr/\x00//d; # a.k.a. "y///" : y/\x00//d;
If you think you really are doing something like that, and it's not working for you, then you'll have to show a working demonstration of the code that proves it doesn't work.perl -e 'print "foo\x00bar" | xxd -g 1 # produces this output (note the null byte): 0000000: 66 6f 6f 00 62 61 72 foo.bar perl -e 'print "foo\x00bar" | perl -pe 's/\x00+//g' | xxd -g 1 # produces this output (no null byte): 0000000: 66 6f 6f 62 61 72 foobar
My guess is you're doing something else wrong elsewhere in your code, unrelated to the regex. (If your program doesn't use strict; then it might be something as simple as a spelling error in a variable name.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: striping nulls
by sans-clue (Beadle) on Oct 01, 2010 at 02:15 UTC | |
by ww (Archbishop) on Oct 01, 2010 at 03:07 UTC | |
by ikegami (Patriarch) on Oct 01, 2010 at 03:37 UTC |