Intersection and Subtraction Clusters

0

I have a question regarding regular expressions. I do not understand how intersection and subtraction work in regular expressions. Could someone clarify me?

[a-z&&[aeiou]]  Interseção
[a-z&&[^m-p]]   Subtração
System.out.println("O QUE PODE FICAR AQUI PARA SER VERDADEIRO?".matches("[a-z&&[aeiou]]"));
System.out.println("O QUE PODE FICAR AQUI PARA SER VERDADEIRO?".matches("[a-z&&[^m-p]]"));
    
asked by anonymous 15.02.2015 / 00:36

1 answer

0

As the name already says, the intersection will intersect two regular expressions. That is, the intersection of n regular expressions is a regular expression that will match if all n subexpressions also give match .

> der match and the regular expression b does not match.

In the case of expression [a-z&&[aeiou]] , String a gives match in the a-z subexpression and also gives match in the [aeiou] subexpression. Soon it gives match in the expression [a-z&&[aeiou]] . On the other hand, String b only gives match in the first subexpression, so it does not match match in the complete expression.

In the case of expression [a-z&&[^m-p]] , String a gives match in the subexpression a-z and also gives match in the [^m-p] subexpression (because a is not between m and p ). Soon it gives match in the expression [a-z&&[^m-p]] . On the other hand, String gives match in the first subexpression but does not match the second because m is between m and m , so it does not match in the full expression.

    
15.02.2015 / 01:13