Semantically, is a Regex can be "contained" by a String? As Liz wrote, a regex is "matched" against a String.
Besides that, I'm wondering if the smart match operator ~~ can be used as a method call? "foobar".smart-match( /'foo'/ ).say in place of ( "foobar" ~~ /'foo'/ ).say AFAIK, it exists the ACCEPTS method, but it have to be called on the right operand : /'foo'/.ACCEPTS( 'foobar' ); 2017-06-12 22:14 GMT+02:00 Will Coleda <w...@coleda.com>: > On Mon, Jun 12, 2017 at 4:07 PM, Elizabeth Mattijsen <l...@dijkmat.nl> > wrote: > >> On 12 Jun 2017, at 22:04, Will Coleda <w...@coleda.com> wrote: > >> On Mon, Jun 12, 2017 at 5:17 AM, Francesco Rivetti <o...@oha.it> wrote: > >>> if you can: > >>> > >>> $s ~~ "foo" > >>> $s ~~ /foo/ > >>> > >>> then wouldn't be good to have also: > >>> > >>> $s.contains("foo"); > >>> $s.contains(/foo/); > >> > >> The latter is currently available as: > >> > >>> "foobar".match(/'foo'/); > >> 「foo」 > > > > That’s not entirely true, as .contains returns a Bool:D, not a Match > object. It *could* be interesting to not have to build the entire Match > object somehow and just return a Bool:D in case of contains. > > > > > > Liz > > Sorry, you're right, it's: > > ?"foobar".match(/'foo'/); > > > -- > Will "Coke" Coleda > -- Julien Simonet