473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to seperate words?

Hi all,

I have a query like this:-

((A AND B) NOT (C AND D) AND (N OR M) NOT (E AND F))

I want to store
((A AND B) AND (N OR M)) in one array.

(C AND D) NOT (E AND F) in other array.

means NOT terms in one array other terms in other array in perl.

How do i do that?

pls help me.

with regards
Archana
Sep 10 '07 #1
9 1584
KevinADC
4,059 Expert 2GB
I am totally confused by your question. Have you tried any code yet we can look at?
Sep 10 '07 #2
basically the query is like this :-
((A AND B) NOT (C AND D) AND (E OR F) NOT (N AND M))

i want to separate the terms i.e

(A AND B) AND (E OR F) something like rearrangement without NOT terms.

and NOT terms in separate array.

finally my output:-
a)(A AND B) AND (E OR F)
b)(C AND D) NOT (N AND M)

more specifically NOT terms in one array and other terms in other array.
Sep 11 '07 #3
KevinADC
4,059 Expert 2GB
how do you know (A AND B) belongs in the AND group? There is no AND or NOT in front of it. Have you tried any code yet we can look at? (he asks for the second time).
Sep 11 '07 #4
numberwhun
3,509 Expert Mod 2GB
basically the query is like this :-
((A AND B) NOT (C AND D) AND (E OR F) NOT (N AND M))

i want to separate the terms i.e

(A AND B) AND (E OR F) something like rearrangement without NOT terms.

and NOT terms in separate array.

finally my output:-
a)(A AND B) AND (E OR F)
b)(C AND D) NOT (N AND M)

more specifically NOT terms in one array and other terms in other array.
Archanak,

I have to agree with Kevin 100%. You really need to post the code that you have tried thus far so that we can help you troubleshoot it. We won't write your script, but will certainly troubleshoot it with you so you can learn.

Regards,

Jeff
Sep 11 '07 #5
how do you know (A AND B) belongs in the AND group? There is no AND or NOT in front of it. Have you tried any code yet we can look at? (he asks for the second time).
Hi Kevin,

suppose my query is like this:-
((A AND B) NOT (C AND D) AND (M AND N) NOT (P OR Q))

i tried like this:-

Expand|Select|Wrap|Line Numbers
  1. if($query=~/(.*)\sNOT\s\(([^()]+)\)(.*)/g)
  2. {
  3.         $key=$1;
  4.         $sec=$2;
  5.         $third=$3;
  6.         print "<br>first =$key<br>";
  7.         print "<br>second=$sec<br>";
  8.         print "<br>third=$third<br>";
  9.         $final=$key."".$third;
  10.         print "<br>****final value=$final<br>";
  11.         if($final=~/(.*)\sNOT\s\(([^()]+)\)(.*)/)
  12.         {
  13.                 $term=$1;
  14.                 $sterm=$2;
  15.                 $lterm=$3;
  16.                 print "< br>TERM=**************$1**<br>";
  17.                 print "<br>STERM=******$2<br>";
  18.                 print "<br>LTERM=*****$3<br>";
  19.     }
  20. }
  21.  
i.e first i have used regular expression to filter NOT terms

i have stored the terms in $1, $2& $3
and check again if it has NOT terms then again store $1,$2....

But if many NOT terms this will not work.
Sep 11 '07 #6
numberwhun
3,509 Expert Mod 2GB
Archanak,

I have edited your post and corrected it for top posting. Please do not put your replies above the quoted text, otherwise

flow.
natural
conversations
the
follow
easily
wont
we

Regards,

Jeff
Sep 11 '07 #7
KevinADC
4,059 Expert 2GB
Hi Kevin,

suppose my query is like this:-
((A AND B) NOT (C AND D) AND (M AND N) NOT (P OR Q))


But if many NOT terms this will not work.
You need to create a list of the pattern matches. Generally you can do that by returning the value of a regexp to an array and use the "g" option with your regexp.


@list = $foo =~ /(pattern)/g;
Sep 11 '07 #8
You need to create a list of the pattern matches. Generally you can do that by returning the value of a regexp to an array and use the "g" option with your regexp.


@list = $foo =~ /(pattern)/g;
Hi kevin,

can u explain more about how to implement?

with regards
Sep 13 '07 #9
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. my $string = '((A AND B) NOT (C AND D) AND (E OR F) NOT (N AND M))';
  2. my @not = $string =~ /NOT (\(\w AND \w\))/g;
Sep 13 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Karl Rhodes | last post by:
Ok, we think we have a problem which SHOULD be simple to resolve but appears to be impossible (unless we're not as good as we thought we were!!!) We have seperate workstations on which we do our...
7
by: Shannan Casteel via AccessMonster.com | last post by:
I have a form for entering part numbers along with the associated quantity for each part. There are 25 Part fields and 25 associated Quantity fields. If I go to record 1 and enter part number 1234...
9
by: ern | last post by:
I'm using scanf("%s",userInput) to capture up to three words from the user. I want to seperate those three words into three variables: char * firstWord; char * secondWord; char * thirdWord; ...
8
by: Serge | last post by:
Hi, I have some intensive code that is running on my main thread. I try to show a status update on a 'status form'. The problem that i have is that because it is running in the same thread the...
12
by: Brian Keating EI9FXB | last post by:
Hello all, Wonder what approach is used for this problem. I have a MDIApplication, the MDIClinets are to be in a seperate thread. So I've done something like this, // Create a new Show...
8
by: feng | last post by:
In our VB.Net application, we need to be able to start another process (thread won't do it) and run some logic in it, and still be able to communicate with the main process. Is this possible and...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
0
by: bloukopkoggelmander | last post by:
Hi All wonderfull brains! Right I have two questions after my last very successfull thread. I have tried looking these up on the net, but no luck. Scenario 1 is : I have a bound form with bound...
5
by: cmrhema | last post by:
Hello I want to separate or say split a string. Eg. I have a word Client Server It should be split as Client Server I went and searched and got it string MainString = "String...
2
by: desertavataraz | last post by:
I am going write an application in C++ that allows the user to see two languages at once, and allows them to search each individual language for words or keywords. I have a font that I made...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.