in reply to Re: Check if a word is included in another
in thread Check if a word is included in another

This is not counting the number of times a letter appears.
  • Comment on Re^2: Check if a word is included in another

Replies are listed 'Best First'.
Re^3: Check if a word is included in another
by BrowserUk (Patriarch) on Apr 18, 2010 at 22:49 UTC

    Did you try it?

    print wordCheck( 'onlyones', $_ ) for qw[ none noon noone lyoness ]; 1 1 1

    Perhaps this will clarify:

    sub wordCheck{ my $s = join '', sort split'', $_[0]; my $re = join'.*', sort split'', $_[1]; print "doing: $s =~ $re"; return $s =~ $re; } print wordCheck( 'onlyones', $_ ) for qw[ none noon noone lyoness ];; doing: elnnoosy =~ e.*n.*n.*o 1 doing: elnnoosy =~ n.*n.*o.*o 1 doing: elnnoosy =~ e.*n.*n.*o.*o 1 doing: elnnoosy =~ e.*l.*n.*o.*s.*s.*y
      I did, but made the mistake of swapping the target and the word, so that the results came out wrong. Sorry for the complaint. Otherwise this is really very pretty. Of course credit also goes to jwkrahn for starting this thread.