erogol
erogol

Reputation: 13614

Regular expression for all characters except 0 and 1 in Perl

I try to find number of occurrence of 011 in binary strings that are delimited by any other (e.g. 11100011/100010-01110a0011100b) characters. So I need to say allcharacters-[0,1] somewhere in my code to use split function. How could I say it in regular expression...

Upvotes: 2

Views: 535

Answers (1)

user149341
user149341

Reputation:

You can invert a character set by prefixing it with ^:

[^01]

In this case, however, you don't need to use split at all:

my @binary_strings = $input =~ m{[01]+}g;

Upvotes: 7

Related Questions