Reputation: 41
I need a regex to not match tab, carriage return and square brackets. (C#)
Upvotes: 4
Views: 12630
Reputation: 455322
Try:
[^\][\t\r]
[]
- char class^
- negation of char class.\]
- escape ] as ] is a meta char
inside a char class[
- need not escape [
as inside []
its not a meta char\t
- tab\r
- return carriageUpvotes: 5
Reputation: 118158
#!/usr/bin/perl
use strict; use warnings;
my ($s) = @ARGV;
if ( $s =~ /^[^\r\t\[\]]*\z/ ) {
print "$s contains no carriage returns, tabs or square brackets\n";
}
Upvotes: 0
Reputation: 21730
[\w]+
Will match any word character (alphanumeric & underscore).
Upvotes: 0