I think you want `String#[] `  for example:
 "sample"[/\d+/]
 # => nil

"sample123"[/\d+/]

# => '123'


botp <botpena / gmail.com>в2016ǯ1117 12:29ƻ

> On Thu, Nov 17, 2016 at 8:00 AM, Die Optimisten
> <inform / die-optimisten.net> wrote:
> > How can I emulate a short form similar to (the non-existing)
> string.include
> > /regex/ ?
> > maybe immediately returning nil or the full-string ?
>
> do you mean
>
> ri String#match
> ri String#=~
>
> ?
>
> show sample code pls.
>
> best regards
> --botp
>
> Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>