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

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 1568
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Felix Collins | last post by:
Hi, I'm not a regexp expert and had a bit of trouble with the following search. I have an "outline number" system like 1 1.2 1.2.3 1.3
4
by: Joseph | last post by:
The idea is to show only one of the <Baby_Div> while hiding all the others. At the moment all I have managed to do is to show each <Baby_Div> in turn as expected, but the problem is that once a...
21
by: google | last post by:
I'm trying to implement something that would speed up data entry. I'd like to be able to take a string, and increment ONLY the right-most numerical characters by one. The type structure of the...
32
by: Licheng Fang | last post by:
Basically, the problem is this: 'do' Python's NFA regexp engine trys only the first option, and happily rests on that. There's another example: 'oneself' The Python regular expression...
23
by: codefire | last post by:
Hi, I am trying to get a regexp to validate email addresses but can't get it quite right. The problem is I can't quite find the regexp to deal with ignoring the case james..kirk@fred.com, which...
7
by: VUNETdotUS | last post by:
How can I get the text after matching string is found: var str = "1111>AAAA<2222>BBBB<3333>CCCC"; if(str.indexOf("2222>")){ //how to get "BBBB" value following my "2222>" but before "<3333"...
8
by: Tim Nash (aka TMN) | last post by:
Hi Can anyone help me match this div below - my regex does not work - if you could tell me why I would appreciate it. var aStr = "<div class='feedflare'>dfgdg dg</div>"; var reg = new...
4
by: Andrew Poulos | last post by:
I have a string that looks like this "cmi.interactions.fred.id" I need to test that: - the first part of the string is "cmi.interactions." (case sensitive). - the last part of the string is...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
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: 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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.