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

RegEx question

Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
50
vvvv
50
I have a solution by which I read line and filter the ones which I want...
Is there a way I can get it via Regular Expression,. Somehow this expression
is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA
Nov 16 '05 #1
8 1261
You'll have to give examples as to the range of possible values and what you want to extract.
For instance, say
for "50abcde" I want to extract "abcde"
for "51abcde" ???
for "5034698ghijk" ???
for "5100euiyq" ???
for "0x32THISISINHEX" ???
for " 5 0 r21" ???

more info needed


"Vai2000" wrote:
Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
50
vvvv
50
I have a solution by which I read line and filter the ones which I want...
Is there a way I can get it via Regular Expression,. Somehow this expression
is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA

Nov 16 '05 #2
Sorry for the poor explanation.
I want to grab records which start with 50

TIA

"Beeeeeeeeeeeeves" <Be**************@discussions.microsoft.com> wrote in
message news:24**********************************@microsof t.com...
if you can't provide more info I would suggest @"(?<=^50)[\s\S]*"
"Vai2000" wrote:
Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
5010100.....
vvvv
508744
I have a solution by which I read line and filter the ones which I want... Is there a way I can get it via Regular Expression,. Somehow this expression is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA

Nov 16 '05 #3
"Vai2000" <no****@microsoft.com> wrote in
news:eX*************@TK2MSFTNGP10.phx.gbl:
Sorry for the poor explanation.
I want to grab records which start with 50


You can use the System.String.StartsWith method.

Example:

string s = "50 Lines";
bool b = s.StartsWith("50");

If leading spaces are to be ignored, then simply trim the string:

string s = "50 Lines";
bool b = s.TrimStart(null).StartsWith("50");
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #4
Thanks Chris, Though as I mentioned in my post, I have the soln u
suggested,, was looking for only RegEx solution.

Thanks for comment though

"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
"Vai2000" <no****@microsoft.com> wrote in
news:eX*************@TK2MSFTNGP10.phx.gbl:
Sorry for the poor explanation.
I want to grab records which start with 50


You can use the System.String.StartsWith method.

Example:

string s = "50 Lines";
bool b = s.StartsWith("50");

If leading spaces are to be ignored, then simply trim the string:

string s = "50 Lines";
bool b = s.TrimStart(null).StartsWith("50");
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Nov 16 '05 #5
Hi,
inline

"Vai2000" <no****@microsoft.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
50
vvvv
50
I have a solution by which I read line and filter the ones which I want... Is there a way I can get it via Regular Expression,. Somehow this expression is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");
try:
Regex reISA = new Regex(@"^50.*$", RegexOptions.Multiline);

HTH,
greetings

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA

Nov 16 '05 #6
Hi,
inline

"Vai2000" <no****@microsoft.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
50
vvvv
50
I have a solution by which I read line and filter the ones which I want... Is there a way I can get it via Regular Expression,. Somehow this expression is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");
try:
Regex reISA = new Regex(@"^50.*$", RegexOptions.Multiline);

HTH,
greetings

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA

Nov 16 '05 #7
u are the man

Thanks

"BMermuys" <so*****@someone.com> wrote in message
news:pv**********************@phobos.telenet-ops.be...
Hi,
inline

"Vai2000" <no****@microsoft.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
50
vvvv
50
I have a solution by which I read line and filter the ones which I

want...
Is there a way I can get it via Regular Expression,. Somehow this

expression
is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");


try:
Regex reISA = new Regex(@"^50.*$", RegexOptions.Multiline);

HTH,
greetings

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA


Nov 16 '05 #8
u are the man

Thanks

"BMermuys" <so*****@someone.com> wrote in message
news:pv**********************@phobos.telenet-ops.be...
Hi,
inline

"Vai2000" <no****@microsoft.com> wrote in message
news:uY**************@TK2MSFTNGP10.phx.gbl...
Hi All, I have a file which has some lines starting with value 50.
xxx
xxx
50
vvvv
50
I have a solution by which I read line and filter the ones which I

want...
Is there a way I can get it via Regular Expression,. Somehow this

expression
is not working...please correct.

Regex reISA = new Regex(@"^[5][0]");


try:
Regex reISA = new Regex(@"^50.*$", RegexOptions.Multiline);

HTH,
greetings

MatchCollection mGS = reISA.Matches(filecontent); // file read via
streamreader into a string content

foreach (Match m in mGS){

System.Diagnostics.Debug.WriteLine(m.Index+" "+m.Value);

}
TIA


Nov 16 '05 #9

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

Similar topics

4
by: engwar1 | last post by:
Not sure where to ask this. Please suggest another newsgroup if this isn't the best place for this question. I'm new to both vb.net and regex. I need a regular expression that will validate what...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: Tim Conner | last post by:
Hi, Thanks to Peter, Chris and Steven who answered my previous answer about regex to split a string. Actually, it was as easy as create a regex with the pattern "/*-+()," and most of my string...
6
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
5
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
6
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead"....
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
6
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character...
6
by: | last post by:
Hi all, Sorry for the lengthy post but as I learned I should post concise-and-complete code. So the code belows shows that the execution of ValidateAddress consumes a lot of time. In the test...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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.