469,081 Members | 1,886 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,081 developers. It's quick & easy.

Help me with REGEXP please !

B.
Hello, I've got the following problem: Suppose you have the strings
contains:

"xxxx aaa { 111, 222, 333} bbb {111, 222,333} yyyy"
"xxxx aaa {1112, 2223, 3334} bbb {11112, 22223,33334,44445} yyyy"
I need to select only those strings which match the sequence aaa {...}
with number 222 inside brackets. Number 222 can be of course at any
position inside brackets e.g. aaa {222, 333, 111}, or aaa
{111,333,222}.
How to do this with REGEXP ? Something like this:

1. find aaa
2. skip zero or more white chars until '{'
3. find sequence: "222 , ... }" or " ..., 222 , ...}" or "..., 222 }"

thanks for the help.
B.Sveton
Jul 20 '05 #1
8 1442
"B." <bo****@yahoo.com> wrote in message
"xxxx aaa { 111, 222, 333} bbb {111, 222,333} yyyy"
"xxxx aaa {1112, 2223, 3334} bbb {11112, 22223,33334,44445} yyyy"
I need to select only those strings which match the sequence aaa {...}
with number 222 inside brackets. Number 222 can be of course at any
position inside brackets e.g. aaa {222, 333, 111}, or aaa
{111,333,222}.
How to do this with REGEXP ? Something like this:


Didn't try it, but this might work for the regular expression:

..*aaa {.*222.*}.*
Jul 20 '05 #2
"B." <bo****@yahoo.com> wrote in message
"xxxx aaa { 111, 222, 333} bbb {111, 222,333} yyyy"
"xxxx aaa {1112, 2223, 3334} bbb {11112, 22223,33334,44445} yyyy"
I need to select only those strings which match the sequence aaa {...}
with number 222 inside brackets. Number 222 can be of course at any
position inside brackets e.g. aaa {222, 333, 111}, or aaa
{111,333,222}.
How to do this with REGEXP ? Something like this:


Didn't try it, but this might work for the regular expression:

..*aaa {.*222.*}.*
Jul 20 '05 #3
B.
"Siemel Naran" <Si*********@REMOVE.att.net> wrote in message news:<lf*********************@bgtnsc05-news.ops.worldnet.att.net>...
"B." <bo****@yahoo.com> wrote in message
"xxxx aaa { 111, 222, 333} bbb {111, 222,333} yyyy"
"xxxx aaa {1112, 2223, 3334} bbb {11112, 22223,33334,44445} yyyy"
I need to select only those strings which match the sequence aaa {...}
with number 222 inside brackets. Number 222 can be of course at any
position inside brackets e.g. aaa {222, 333, 111}, or aaa
{111,333,222}.
How to do this with REGEXP ? Something like this:


Didn't try it, but this might work for the regular expression:

.*aaa {.*222.*}.*


I don't think so. It finds also aaa {111, 2222, 333} and 2222 != 222 :-(

B.
Jul 20 '05 #4
B.
"Siemel Naran" <Si*********@REMOVE.att.net> wrote in message news:<lf*********************@bgtnsc05-news.ops.worldnet.att.net>...
"B." <bo****@yahoo.com> wrote in message
"xxxx aaa { 111, 222, 333} bbb {111, 222,333} yyyy"
"xxxx aaa {1112, 2223, 3334} bbb {11112, 22223,33334,44445} yyyy"
I need to select only those strings which match the sequence aaa {...}
with number 222 inside brackets. Number 222 can be of course at any
position inside brackets e.g. aaa {222, 333, 111}, or aaa
{111,333,222}.
How to do this with REGEXP ? Something like this:


Didn't try it, but this might work for the regular expression:

.*aaa {.*222.*}.*


I don't think so. It finds also aaa {111, 2222, 333} and 2222 != 222 :-(

B.
Jul 20 '05 #5
"B." <bo****@yahoo.com> wrote in message
"Siemel Naran" <Si*********@REMOVE.att.net> wrote in message

news:<lfOnc.39725
Didn't try it, but this might work for the regular expression:

.*aaa {.*222.*}.*


I don't think so. It finds also aaa {111, 2222, 333} and 2222 != 222 :-(


OK. Maybe the beginning and end of word markers might help

..*aaa {.*[[:<:]]222[[:>:]].*}.*

Also, I don't think we need the leading and trailing .*, as that's
automatic, so

aaa {.*[[:<:]]222[[:>:]].*}

Now is { or } a special character too?
Jul 20 '05 #6
B.
"Siemel Naran" <Si*********@REMOVE.att.net> wrote in message news:<%E*********************@bgtnsc05-news.ops.worldnet.att.net>...
"B." <bo****@yahoo.com> wrote in message
"Siemel Naran" <Si*********@REMOVE.att.net> wrote in message news:<lfOnc.39725
Didn't try it, but this might work for the regular expression:

.*aaa {.*222.*}.*


I don't think so. It finds also aaa {111, 2222, 333} and 2222 != 222 :-(


OK. Maybe the beginning and end of word markers might help

.*aaa {.*[[:<:]]222[[:>:]].*}.*

Also, I don't think we need the leading and trailing .*, as that's
automatic, so

aaa {.*[[:<:]]222[[:>:]].*}

don't work at all :-( the expression also finds
"aaa {111, 333, 444} bbb {111,222,333}" because .* at the end skips
any number of chars which is always true, but i need to limit search
only between {} brackets. i can of course replace {} chars with
anything else, e.g. quotes, or double quotes, or () brackets, but the
search must be always limited between those chars. thanks once again
for the help.

B.


Now is { or } a special character too?

Jul 20 '05 #7
"B." <bo****@yahoo.com> wrote in message > "Siemel Naran"
<Si*********@REMOVE.att.net
aaa {.*[[:<:]]222[[:>:]].*}
don't work at all :-( the expression also finds
"aaa {111, 333, 444} bbb {111,222,333}" because .* at the end skips


Oops, I thought that's what you wanted as the 222 is within brackets. But
it has to be between the brackets right after the aaa. If so I think you
should replace any numbers of characters .* with any number of characters
that are not braces.

aaa {[^}]*[[:<:]]222[[:>:]][^{]*}

This means aaa, followed by space, followed by {, followed by any number of
chars that are not the close brace }, followed by 222 as a single word, etc.
The one thing to wonder about is what is the definition of a word.

any number of chars which is always true, but i need to limit search
only between {} brackets. i can of course replace {} chars with
anything else, e.g. quotes, or double quotes, or () brackets, but the
search must be always limited between those chars. thanks once again
for the help.

B.


Now is { or } a special character too?

Jul 20 '05 #8
B.
"Siemel Naran" <Si*********@REMOVE.att.net> wrote in message news:<q2*********************@bgtnsc05-news.ops.worldnet.att.net>...
"B." <bo****@yahoo.com> wrote in message > "Siemel Naran"
<Si*********@REMOVE.att.net
aaa {.*[[:<:]]222[[:>:]].*}


don't work at all :-( the expression also finds
"aaa {111, 333, 444} bbb {111,222,333}" because .* at the end skips


Oops, I thought that's what you wanted as the 222 is within brackets. But
it has to be between the brackets right after the aaa. If so I think you
should replace any numbers of characters .* with any number of characters
that are not braces.

aaa {[^}]*[[:<:]]222[[:>:]][^{]*}

This means aaa, followed by space, followed by {, followed by any number of
chars that are not the close brace }, followed by 222 as a single word, etc.
The one thing to wonder about is what is the definition of a word.

any number of chars which is always true, but i need to limit search
only between {} brackets. i can of course replace {} chars with
anything else, e.g. quotes, or double quotes, or () brackets, but the
search must be always limited between those chars. thanks once again
for the help.

B.


Now is { or } a special character too?


yes, it works :-) many thanks.

B>
Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Felix Collins | last post: by
4 posts views Thread by Joseph | last post: by
23 posts views Thread by codefire | last post: by
7 posts views Thread by VUNETdotUS | last post: by
8 posts views Thread by Tim Nash (aka TMN) | last post: by
4 posts views Thread by Andrew Poulos | last post: by
5 posts views Thread by jrod11 | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.