Groovy: различия между версиями
Содержимое удалено Содержимое добавлено
Moriline (обсуждение | вклад) |
Moriline (обсуждение | вклад) |
||
Строка 837:
</syntaxhighlight>
== Regular Expressions (Регулярные выражения) ==
===
Оператор pattern (~) обеспечивает простой способ создать java.util.regex.Pattern.<br />
Пример:
Строка 858:
# использование GString
=== Find
Alternatively to building a pattern, you can directly use the find operator =~ to build a java.util.regex.Matcher instance:
<syntaxhighlight lang="groovy">
Строка 873:
Since a Matcher coerces to a boolean by calling its find method, the =~ operator is consistent with the simple use of Perl’s =~ operator, when it appears as a predicate (in if, while, etc.).
=== Match
The match operator (==~) is a slight variation of the find operator, that does not return a Matcher but a boolean and requires a strict match of the input string:
<syntaxhighlight lang="groovy">
|