Gilles wrote:
Hi,

I try do to a < simple > thing :

Knowing If a string like "13" exist in a string like "123"

Or if "37" exist in "12356789"

I tried many solutions, but never found one good so I try to do it with
loops which more difficult but not impossible

I'd like to know if with RegExp  it's more simply

If you just want to see if the string "13" is found within the string "123", you can use the index() function:

   $found = index('123', '13') >= 0;
   ==> false

or a simple regex:

   $found = '123' =~ /13/;
   ==> false

If you want to know whether '123' contains both a '1' and a '3', you can do something like this:

   $found = !grep $_ < 0, map index('123', $_), split '', '13';
   ==> true


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to