473,379 Members | 1,330 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,379 software developers and data experts.

pcre.c : And Operator

Hi,
I'm using pcre.c to provide regex support for my application
software. I want to know how to do 'AND' operation in this. I didn't
got any useful info from the net.

Is this operator available or not? If not how could we do this
operation? Any stuffed replies or redirection will be appreciated.

Thanks,
Ganesh

Nov 14 '05 #1
17 2081
sg*******@yahoo.co.in wrote:
Hi,
I'm using pcre.c to provide regex support for my application
software. I want to know how to do 'AND' operation in this. I didn't
got any useful info from the net.

Is this operator available or not? If not how could we do this
operation? Any stuffed replies or redirection will be appreciated.

Thanks,
Ganesh


What on earth is an AND operator in a regular expression?

gtoomey
Nov 14 '05 #2
>> What on earth is an AND operator in a regular expression?

If you have an OR ( | ) operator, where is the ( & )

Nov 14 '05 #3
sg*******@yahoo.co.in wrote:
What on earth is an AND operator in a regular expression?


If you have an OR ( | ) operator, where is the ( & )


From http://www.perl.com/doc/manual/html/pod/perlre.html
| is alternation

ie [a|b|c]x will match ax or bx or cx

But there is no & as its meaningless. Suppose your could have [a&b&c]x . It
would need to ax and bx and cx simultaneously which is impossible. Its
meaningless.

gtoomey
Nov 14 '05 #4
>> would need to ax and bx and cx simultaneously which is
impossible. Its meaningless.


"match ax bx cx". I want to match ax,bx,cx in the string. How can I do
this then. If one of these there is not there then it should print
false.

-Ganesh

Nov 14 '05 #5
sg*******@yahoo.co.in scribbled the following:
would need to ax and bx and cx simultaneously which is
impossible. Its meaningless.
"match ax bx cx". I want to match ax,bx,cx in the string. How can I do
this then. If one of these there is not there then it should print
false.


What do you mean by "match ax bx cx" or "match ax,bx,cx"? What
*specific* criterion should the string match?
Do you mean any string that includes *all* of "ax", "bx" and "cx", not
just any one of them? If so, then one very awkward way would be
something like:
(*ax*bx*cx*)|(*ax*cx*bx*)|(*bx*ax*cx*)|(*bx*cx*ax* )|(*cx*ax*bx*)|
(*cx*bx*ax*)
I think there's a shorter way but I can't come up with one now. If
that's not what you want, then what is?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Shh! The maestro is decomposing!"
- Gary Larson
Nov 14 '05 #6
On Thu, 17 Feb 2005 01:53:22 -0800, sgane2001 wrote:
would need to ax and bx and cx simultaneously which is
impossible. Its meaningless.


"match ax bx cx". I want to match ax,bx,cx in the string. How can I do
this then. If one of these there is not there then it should print
false.


Regular expressions can't do that directly. The simplest way is probaby to
perform 3 separate searches.

Lawrence
Nov 14 '05 #7
some incidental interloper responded to someone who wrote:

[Regarding the '&' operator in regular expressions...]
would need to ax and bx and cx simultaneously which is
impossible. Its meaningless.


Forgive me for not responding to the orignal article,
my news server has lost track of it.

The '&' operator isn't meaningless, it means language
intersection. (At least, that's a reasonable guess.)

So, the expression

(a|b|c)&(c|d|e)

would be the same as the expression

c

or, for another example

[a-n]&[i-z]

would be the same as the expression

[i-n]

In these examples only letters are literal characters,
others are all meta-characters.

Can interested parties take this discussion to a newsgroup
more appropriate than comp.lang.c? Thank you.
Nov 14 '05 #8
Lawrence Kirby wrote:
On Thu, 17 Feb 2005 01:53:22 -0800, sgane2001 wrote:

.... snip ...

"match ax bx cx". I want to match ax,bx,cx in the string. How
can I do this then. If one of these there is not there then it
should print false.


Regular expressions can't do that directly. The simplest way is
probaby to perform 3 separate searches.


Factor it. [a|b|c]x

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

Nov 14 '05 #9
Factor it. [a|b|c]x


What I want is, match all the patterns in the given string. I knew that
we can match all the patterns if they are given in order of occurance.
But how to do that in case of un-ordered patterns.

Ex: String ---> "Match the occurances of "match", "this" in this
string"

String =~ /'this' & 'match'/ . How can I do this?

Nov 14 '05 #10
CBFalconer wrote:
Lawrence Kirby wrote:
On Thu, 17 Feb 2005 01:53:22 -0800, sgane2001 wrote:


... snip ...
"match ax bx cx". I want to match ax,bx,cx in the string. How
can I do this then. If one of these there is not there then it
should print false.


Regular expressions can't do that directly. The simplest way is
probaby to perform 3 separate searches.

Factor it. [a|b|c]x


You seem to have misunderstood the problem:
ax _and_ bx _and_ cx have to be in the string but in
arbitrary order. I think that short of writing out
(ax.*bx.*cx) | (ax.*cx.*bx) | .....
which gets increasingly long (n! for n different substrings to match)
you really should just run through the subexpressions to be tested
and find whether each matches individually.
Consistency checks beforehand left as exercise :-)
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #11
On Thu, 17 Feb 2005 21:08:25 -0800, sgane2001 wrote:
Factor it. [a|b|c]x


What I want is, match all the patterns in the given string. I knew that
we can match all the patterns if they are given in order of occurance.
But how to do that in case of un-ordered patterns.

Ex: String ---> "Match the occurances of "match", "this" in this
string"

String =~ /'this' & 'match'/ . How can I do this?


Methods have already been covered. Regular expressions aren't really a
good way to solve this. Also consider if the strings you want to consider
are, say "match" and "matchstick", would the string "matchstick" match
both or do the pattern strings have to exist separately?

This isn't a discussion of the C programming language, maybe a newsgroup
such as comp.programming would be more appropriate.

Lawrence

Nov 14 '05 #12
On 17 Feb 2005 21:08:25 -0800, sg*******@yahoo.co.in
<sg*******@yahoo.co.in> wrote:
Factor it. [a|b|c]x


What I want is, match all the patterns in the given string. I knew that
we can match all the patterns if they are given in order of occurance.
But how to do that in case of un-ordered patterns.

Ex: String ---> "Match the occurances of "match", "this" in this
string"

String =~ /'this' & 'match'/ . How can I do this?


You can't using regular expressions, except by matching each of the
strings separately:

/this/ && /match/

As you have been told, this is off-topic for comp.lang.c, ask in a group
which is about regular expression, or since pcre.c is for Perl type REs
ask in a Perl group. Or since you have the source of pcre.c, and it is
Free Software, you can modify it yourself. Or even email the author...

Chris C
Nov 14 '05 #13

Chris Croughton wrote:
As you have been told, this is off-topic for comp.lang.c, ask in a group which is about regular expression, or since pcre.c is for Perl type REs ask in a Perl group. Or since you have the source of pcre.c, and it is Free Software, you can modify it yourself. Or even email the author...
Chris C


It's not me who diverted the topic, I just wanted to know whether there
is an operator for performing '&' Operation in that 'C' Free Ware and
if so how to use that. Refer Subject of this message. BTW thanks for
your re-direction.

-Ganesh

Nov 14 '05 #14

Chris Croughton wrote:
As you have been told, this is off-topic for comp.lang.c, ask in a group which is about regular expression, or since pcre.c is for Perl type REs ask in a Perl group. Or since you have the source of pcre.c, and it is Free Software, you can modify it yourself. Or even email the author...
Chris C


It's not me who diverted the topic, I just wanted to know whether there
is an operator for performing '&' Operation in that 'C' Free Ware and
if so how to use that. Refer Subject of this message. BTW thanks for
your re-direction.

-Ganesh

Nov 14 '05 #15
In article <pa****************************@netactive.co.uk> ,
lk****@netactive.co.uk says...
This isn't a discussion of the C programming language,


Hmmm. It isn't?

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Nov 14 '05 #16
In article <MP************************@news.verizon.net>,
ra*********@FOOverizonBAR.net says...
In article <pa****************************@netactive.co.uk> ,
lk****@netactive.co.uk says...
This isn't a discussion of the C programming language,


Hmmm. It isn't?


Nevermind, I thought you were referring to the newsgroup, but
I think now you were talking about the thread contents.

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Nov 14 '05 #17
Michael Mair wrote:
CBFalconer wrote:
Lawrence Kirby wrote:
On Thu, 17 Feb 2005 01:53:22 -0800, sgane2001 wrote:


... snip ...
"match ax bx cx". I want to match ax,bx,cx in the string. How
can I do this then. If one of these there is not there then it
should print false.

Regular expressions can't do that directly. The simplest way is
probaby to perform 3 separate searches.

Factor it. [a|b|c]x


You seem to have misunderstood the problem:
ax _and_ bx _and_ cx have to be in the string but in
arbitrary order. I think that short of writing out
(ax.*bx.*cx) | (ax.*cx.*bx) | .....
which gets increasingly long (n! for n different substrings to match)
you really should just run through the subexpressions to be tested
and find whether each matches individually.
Consistency checks beforehand left as exercise :-)
Cheers
Michael


I think you're right. The OP is asking to match a permutation.

gtoomey
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: news | last post by:
Hi all, I am a beginner on 'c' and pcre...and I am on windows 2000 and VC6 with all of the patches, etc. The following program leaks lots of memory and I only make 1 pcre call. I read the...
2
by: Bernd Muent | last post by:
Hi together, most of the time I'm using .net framework to programm C++. F.E. I can do the following: Regex* rex; String*...
16
by: mainland | last post by:
I use prce to match string. I define a pcre struct point, then compile, pass pcre struct point to 'pcre_compile'. When complete, Is it necessary to use 'pcre_free' to free pcre struct point. ...
2
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn...
13
by: Wiseman | last post by:
I'm kind of disappointed with the re regular expressions module. In particular, the lack of support for recursion ( (?R) or (?n) ) is a major drawback to me. There are so many great things that can...
1
by: moreati | last post by:
Recently I discovered the re module doesn't support POSIX character classes: Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) on linux2 Type "help", "copyright", "credits" or "license" for...
8
by: redbeardmcg | last post by:
Hi everyone, I'm having an issue splitting a string with preg_split.... Here is a sample string: congestion >= 80 Where >= could also be <=, ==, !=, < or > What I need to accomplish is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.