You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2021/02/01 20:20:00 UTC

[jira] [Commented] (GROOVY-9925) Groovy match operator documentation should contain real examples and slashy strings reminder

    [ https://issues.apache.org/jira/browse/GROOVY-9925?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17276629#comment-17276629 ] 

Paul King commented on GROOVY-9925:
-----------------------------------

We can no doubt improve those examples. All string forms are supported but will require the appropriate escaping of backslashes or dollars as required, e.g.:
{code}
assert '    ' ==~ "^\\s+\$"
assert '    ' ==~ '^\\s+$'
{code}

> Groovy match operator documentation should contain real examples and slashy strings reminder
> --------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9925
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9925
>             Project: Groovy
>          Issue Type: Documentation
>    Affects Versions: 3.0.7
>            Reporter: Alex Fredrickson
>            Priority: Minor
>
> The [3.0.7 Groovy documentation|[https://docs.groovy-lang.org/latest/html/documentation/#_match_operator]] could be more clear on regex usage with match operators, particularly:
>  # It would be helpful to note here that slashy strings are *required* for the match operator to work.  `foo ==~ "^\s+$"` will never work.  I know there's a section dedicated to slashy strings; it would be helpful to have a footnote here.
>  # This section could benefit from a better example than `{{m = text ==~ /match/}}`.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)