Folks,
I'm having a bad regex day and can sure use your help, please..
I have a Regex expression that works fine. It's purpose is to isolate all
data from the start of a string begining with 200~ to the end of the string
but before the start of the next 200~. Here's the regex expression and test
data:
(?ms)^200~(.*?)(?=^200~)
Here's some test data
00000000000000000000
200~11111111111111111
22222222222222222222222222222
3333333333333
200~444444444444444444444444
555555555555555555555555555555555
66666666
200~777777777777777777
888888888888
The regex will return 200~ plus all ones, twos, threes as a group then 200~
plus all fours, fives, sixes as a group
Problem
---------
Now I need to do the reverse. I need to return all the data the preceding
regex doesn't return. IOW, I need to return all the zeros and 200~ plus all
the sevens and all the eights as a group. I want to execute "NOT
(?ms)^200~(.*?)(?=^200~)"
Sure could use a pointer to the correct starting point or any suggestion
that will help me reach my goal.
Thanks in advance
ty_92648 AT hotmail.com 4 1831
I had some rather large explanation of how to do it procedurally, but then I
thought,
"Justin, get off your arse and write some regular expression magic!". So here
you go.
using System;
using System.Text.RegularExpressions;
public class SuperRegex {
private static string stuff =
@"00000000000000000000
200~11111111111111111
22222222222222222222222222222
3333333333333
200~444444444444444444444444
555555555555555555555555555555555
66666666
200~777777777777777777
888888888888";
private static void Main(string[] args) {
Regex regex = new Regex("(?ms)(?:\\A|^200~)(.*?)(?=^200~|\\Z)");
MatchCollection matches = regex.Matches(stuff);
for(int i = 0; i < matches.Count; i++) {
Console.WriteLine();
Console.WriteLine(matches[i].Value);
Console.WriteLine();
}
}
}
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Garibaldi" <ty_92648 AT hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Folks,
I'm having a bad regex day and can sure use your help, please..
I have a Regex expression that works fine. It's purpose is to isolate all data from the start of a string begining with 200~ to the end of the string but before the start of the next 200~. Here's the regex expression and test data:
(?ms)^200~(.*?)(?=^200~)
Here's some test data
00000000000000000000 200~11111111111111111 22222222222222222222222222222 3333333333333 200~444444444444444444444444 555555555555555555555555555555555 66666666 200~777777777777777777 888888888888
The regex will return 200~ plus all ones, twos, threes as a group then 200~ plus all fours, fives, sixes as a group
Problem --------- Now I need to do the reverse. I need to return all the data the preceding regex doesn't return. IOW, I need to return all the zeros and 200~ plus all the sevens and all the eights as a group. I want to execute "NOT (?ms)^200~(.*?)(?=^200~)"
Sure could use a pointer to the correct starting point or any suggestion that will help me reach my goal.
Thanks in advance
ty_92648 AT hotmail.com
You could just call Regex.Replace with the same expression and an empty
string as the replacement if you didn't need to access any of the match
properties (index, groups, etc.).
Brian Davis http://www.knowdotnet.com
"Garibaldi" <ty_92648 AT hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Folks,
I'm having a bad regex day and can sure use your help, please..
I have a Regex expression that works fine. It's purpose is to isolate all data from the start of a string begining with 200~ to the end of the
string but before the start of the next 200~. Here's the regex expression and
test data:
(?ms)^200~(.*?)(?=^200~)
Here's some test data
00000000000000000000 200~11111111111111111 22222222222222222222222222222 3333333333333 200~444444444444444444444444 555555555555555555555555555555555 66666666 200~777777777777777777 888888888888
The regex will return 200~ plus all ones, twos, threes as a group then
200~ plus all fours, fives, sixes as a group
Problem --------- Now I need to do the reverse. I need to return all the data the preceding regex doesn't return. IOW, I need to return all the zeros and 200~ plus
all the sevens and all the eights as a group. I want to execute "NOT (?ms)^200~(.*?)(?=^200~)"
Sure could use a pointer to the correct starting point or any suggestion that will help me reach my goal.
Thanks in advance
ty_92648 AT hotmail.com
Thanks, Brian. Appreciate your suggestion. I'll give a shot.
"Brian Davis" <br***@knowdotnet.nospam.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl... You could just call Regex.Replace with the same expression and an empty string as the replacement if you didn't need to access any of the match properties (index, groups, etc.).
Brian Davis http://www.knowdotnet.com "Garibaldi" <ty_92648 AT hotmail.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Folks,
I'm having a bad regex day and can sure use your help, please..
I have a Regex expression that works fine. It's purpose is to isolate
all data from the start of a string begining with 200~ to the end of the string but before the start of the next 200~. Here's the regex expression and test data:
(?ms)^200~(.*?)(?=^200~)
Here's some test data
00000000000000000000 200~11111111111111111 22222222222222222222222222222 3333333333333 200~444444444444444444444444 555555555555555555555555555555555 66666666 200~777777777777777777 888888888888
The regex will return 200~ plus all ones, twos, threes as a group then 200~ plus all fours, fives, sixes as a group
Problem --------- Now I need to do the reverse. I need to return all the data the
preceding regex doesn't return. IOW, I need to return all the zeros and 200~ plus all the sevens and all the eights as a group. I want to execute "NOT (?ms)^200~(.*?)(?=^200~)"
Sure could use a pointer to the correct starting point or any suggestion that will help me reach my goal.
Thanks in advance
ty_92648 AT hotmail.com
Got it, thanks, Justin!
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl... I had some rather large explanation of how to do it procedurally, but then
I thought, "Justin, get off your arse and write some regular expression magic!". So
here you go.
using System; using System.Text.RegularExpressions;
public class SuperRegex { private static string stuff = @"00000000000000000000 200~11111111111111111 22222222222222222222222222222 3333333333333 200~444444444444444444444444 555555555555555555555555555555555 66666666 200~777777777777777777 888888888888";
private static void Main(string[] args) { Regex regex = new Regex("(?ms)(?:\\A|^200~)(.*?)(?=^200~|\\Z)"); MatchCollection matches = regex.Matches(stuff); for(int i = 0; i < matches.Count; i++) { Console.WriteLine(); Console.WriteLine(matches[i].Value); Console.WriteLine(); } } }
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers
"Garibaldi" <ty_92648 AT hotmail.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... Folks,
I'm having a bad regex day and can sure use your help, please..
I have a Regex expression that works fine. It's purpose is to isolate
all data from the start of a string begining with 200~ to the end of the
string but before the start of the next 200~. Here's the regex expression and
test data:
(?ms)^200~(.*?)(?=^200~)
Here's some test data
00000000000000000000 200~11111111111111111 22222222222222222222222222222 3333333333333 200~444444444444444444444444 555555555555555555555555555555555 66666666 200~777777777777777777 888888888888
The regex will return 200~ plus all ones, twos, threes as a group then
200~ plus all fours, fives, sixes as a group
Problem --------- Now I need to do the reverse. I need to return all the data the
preceding regex doesn't return. IOW, I need to return all the zeros and 200~ plus
all the sevens and all the eights as a group. I want to execute "NOT (?ms)^200~(.*?)(?=^200~)"
Sure could use a pointer to the correct starting point or any suggestion that will help me reach my goal.
Thanks in advance
ty_92648 AT hotmail.com
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Victor Hannak |
last post by:
I have a class with the following public function:
float FuncClass::GetResult() {
try {
return(Result);
} catch (...) {
WriteString("FuncClass::GetResult ERROR: Exception encountered");...
|
by: martlaco1 |
last post by:
Trying to fix a query that (I thought) had worked once upon a time, and
I keep getting a Data Type Mismatch error whenever I enter any criteria
for an expression using a Mid function. Without the...
|
by: Demetri |
last post by:
Lets pretend you have a string array and each element is a
sentence. Two of those elements read as follows:
1. The fox escaped from the hound.
2. The fox almost escaped.
Now lets say you loop...
|
by: Angel |
last post by:
Hi again,
I'm trying to call functions from a proprietary DLL but it's turned out to
be more difficult than I thought.
I have this W32.DLL which was written in C by USPS. They don't provide the...
|
by: Garibaldi |
last post by:
Folks,
I'm having a bad regex day and can sure use your help, please..
I have a Regex expression that works fine. It's purpose is to isolate all
data from the start of a string begining with...
|
by: Paula |
last post by:
Hi !!
What regular expression should I write to get data from an html tag?
Example: <title> The data I want to retrieve </title>
I want to get "The data I want to retrieve"
Could be right...
|
by: howard dierking |
last post by:
Hi all,
I'm having a problem with a reg ex. Essentiall, I'm trying to isolate
variable declarations from old vbscript where there was no explicit
declaration requirement. This should seem easy...
|
by: Kofi |
last post by:
Any takers?
Got a string of DNA as an input sequence GGATGGATG, apply the simple
regex "GGATG" as in
Regex r = new Regex("GGATG", (RegexOptions.Compiled));
MatchCollection matches =...
|
by: rustyc |
last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-)
As I said over there:
... for a little side project at home, I'm writing a ham radio web site in...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |