I have a string like

"The quick brown fox jumps over the lazy dog" (or longer)

I have to search through this string using boolean operators like

"quick AND brown OR fox"

mantaining the logical order, so "quick AND (brown OR fox)".

(consider that the search string can be longer with n search options).

What's the strategy?

How to proceed with this?

With regards

Open an editor and start writing code and testing the results is how you start. School work?


I tried doing like this

$str=quick AND (brown OR fox);

@query=split(/ OR /,$str);

    @andarray=split(/ AND /,$_);
   //perform matching

But this works for small condition but if multiple paranthesis are there i am finding difficult?

for eg:- (brown AND (fox OR well)) like this many boolean conditions..

I don't know what should be done for this?

With regards

Can we use multiple regular expression like this??


use warnings;
use strict;

my $temp_string = "The quick brown fox jumps over the lazy dog";
my $true = 0;

if ($temp_string =~ /\bbrown\b/ || /\bfox\b/)
     if($temp_string =~ /\bquick\b/)
          $true = 1;

if($true == 1)
     print ("The string contains the logical quick AND brown OR fox");
This article has been dead for over six months. Start a new discussion instead.