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

Another one for the Regex gurus

I am attempting to perform some word/phrase tagging, using regular
expressions.

I have the simple case working, looking for the string "one two three" in
the string "one two three four three two one"

My code is then tagging the match and surrounding it with braces, so I would
end up with

"$MATCH1{one two three} four three two one"

Down the line I wind up searching for the single word, "two", but do not
want to match the first occurence which is enclosed within curly braces.

Can anyone help me with the expression to match the second "two" in the
above string, but not the first, which is enclosed within curly braces, but
does not necessarily have the enclosing curly braces right next to the
string you are searching for?

The farthest I could get was something along the lines of

[^{] .+ two .+ [^}]

?

Thanks a bunch in advance!

Derrick
Nov 17 '05 #1
1 924
Your example seems fine. Is there a reason it's not working for you? What is the side effect?

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Derrick" <de*********@excite.com> wrote in message news:eM**************@TK2MSFTNGP15.phx.gbl...
I am attempting to perform some word/phrase tagging, using regular
expressions.

I have the simple case working, looking for the string "one two three" in
the string "one two three four three two one"

My code is then tagging the match and surrounding it with braces, so I would
end up with

"$MATCH1{one two three} four three two one"

Down the line I wind up searching for the single word, "two", but do not
want to match the first occurence which is enclosed within curly braces.

Can anyone help me with the expression to match the second "two" in the
above string, but not the first, which is enclosed within curly braces, but
does not necessarily have the enclosing curly braces right next to the
string you are searching for?

The farthest I could get was something along the lines of

[^{] .+ two .+ [^}]

?

Thanks a bunch in advance!

Derrick

Nov 17 '05 #2

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

Similar topics

33
by: Quest Master | last post by:
I am interested in developing an application where the user has an ample amount of power to customize the application to their needs, and I feel this would best be accomplished if a scripting...
5
by: Ali Eghtebas | last post by:
Hi, I've made this regex to catch the start of a valid multiline comment such as "/*" in e.g. T-SQL code. "(?<=^(?:*'*')*?*)(?<!^(?:*'*')*?--.*)/\*.*?$" With Multiline option on. As we know...
0
by: Justin F | last post by:
I need to parse a string, which contains SQL commands, for the batch terminator ("GO"). I came up with "\s\s" which seems to work as long as there isn't a "GO" in any comments. I have no idea how...
5
by: Gary McCullough | last post by:
What I want to do sounds simple, but it's defeating me. I want to substitute all occurences of a colon : character in a string with an @ character -- unless the : occurs within a single or...
7
by: bill tie | last post by:
I'd appreciate it if you could advise. 1. How do I replace "\" (backslash) with anything? 2. Suppose I want to replace (a) every occurrence of characters "a", "b", "c", "d" with "x", (b)...
6
by: Nurchi BECHED | last post by:
I have a filename and its process id in brackets. The problem is, the filename can contain brackets and numbers in it, but the last number in the brackets is always the process id. Now, assume,...
0
by: Derrick | last post by:
Hi Dave - Thanks, I'll give an easier example, say I have: sodium ion test and I search for "sodium ion test", matching, tagging, I end up with, say TEST${sodium ion test}
7
by: Chris Thunell | last post by:
I'm looking to find in a long string an instance of 4 numbers in a row, and pull out those numbers. For instance: string = "0104 PBR", i'd like to get the 0104. string="PBR XT 0105 TD", i'd like...
5
by: Petra Meier | last post by:
Hello, I use the following script to parse URI and email: function parseLinks($sData){ $regexEmail = "/\w+((-\w+)|(\.\w+))*\@+((\.|-)+)*\.+/"; $sData = preg_replace($regexEmail, "<a...
2
by: slg | last post by:
Gurus, I am new to RegEx. How can i validate following. All characters in my strings are and underscore The string MUST begin with Upper Or lowercase character. Maximum length is 51 can have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.