Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding null character using Regex in Perl

Tags:

regex

perl

I want to find the null characters in an array, which I have. I tried displaying the ASCII value and it printed 0 (So I am confirmed it is a null value). How do I write a regex to filter out those values.

I wrote :

m/^$/ig 

which really didn't help me. Does anybody know how to match a null character ?

like image 836
Somnath Paul Avatar asked Dec 16 '22 11:12

Somnath Paul


1 Answers

You can use \x followed by the hex code of an ASCII character to match that ASCII character.

E.g. /\x3F/ will match a "?", /\x46\x4F\x4F/ to match "FOO".

See it here on Regexr

So /\x00/ would match the NULL character.

like image 111
stema Avatar answered Jan 11 '23 02:01

stema