"!~" can be used to have conditional statements to check if string doesn't match particular regular expression. So that whenever we want to check if particular string is not matching a regular expression we can avoid having negative conditional statements using "unless" like
unless "str" =~ /reg_exp/
# do something
end
We can write this conditional statement as assertive condition as follows:
if "str" !~ /reg_exp/
# do something
end
unless "str" =~ /reg_exp/
# do something
end
We can write this conditional statement as assertive condition as follows:
if "str" !~ /reg_exp/
# do something
end
No comments:
Post a Comment