473,395 Members | 1,815 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.

System.Text.RegularExpressions sintaxis

Hi, I´m using System.Text.RegularExpressions, I want to find any acurrence
of the char & or % or |

Ehat is the correct sintax for the Match method? This is what I´m usinf but
is not working:
Match myMatch = Regex.Match(myString,"^[&|%]*$");

Thanks,

Juan.

Nov 16 '05 #1
2 1258
try the following short program. it find any char & or % or |

class Class1

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args)

{

string myString = "1&2|3%4&5|6%";

Match m = Regex.Match(myString,@"[&\|%]");

int matchCount = 0;

while (m.Success)

{

Console.WriteLine("Match"+ (++matchCount) + "\t\t" + m.Value);

m = m.NextMatch();

}

Console.ReadLine();

}

}
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Juan" <ju*****************@ANTISPAMhotmail.com> wrote in message
news:OU*************@tk2msftngp13.phx.gbl...
Hi, I´m using System.Text.RegularExpressions, I want to find any acurrence
of the char & or % or |

Ehat is the correct sintax for the Match method? This is what I´m usinf but is not working:
Match myMatch = Regex.Match(myString,"^[&|%]*$");

Thanks,

Juan.

Nov 16 '05 #2

"Juan" <ju*****************@ANTISPAMhotmail.com> wrote in message news:OU*************@tk2msftngp13.phx.gbl...
Hi, I´m using System.Text.RegularExpressions, I want to find any acurrence
of the char & or % or |

Ehat is the correct sintax for the Match method? This is what I´m usinf but
is not working:
Match myMatch = Regex.Match(myString,"^[&|%]*$");

Thanks,

Juan.


The ^ and $ mean that the match should be the entire string (instead of
a substring).
The [..]* means that you will match zero or more occurrences of
the specified characters.
The [&|%] means that you will match "&", "|" and "%".

So: you will match only a string consisting entirely of &,| and/or %
characters (or an empty string).

To find any occurrence of one of those three characters, use
"[&|%]" as the RE.

Hans Kesting
Nov 16 '05 #3

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

Similar topics

1
by: Silvina | last post by:
alguien sabe como es la siguiente consulta en my sql??? SELECT IS NULL(Alicuotas.Alicuota_Valor, 0) AS Alicuota1, IS NULL(Alicuotas1.Alicuota_Valor, 0) AS Alicuota2 FROM winmed.Deudores LEFT...
2
by: Doug | last post by:
I'm a little confused by this functionality. It doesn't seem to be behaving like it should. I am using the following regular expression to validate email addresses:...
8
by: Richard Lionheart | last post by:
Hi All, I tried using RegEx, but the compiler barfed with "The type of namespace 'RegEx' could not be found. Prior to this, I had the same problem with MatchCollection, but discovered it's...
0
by: Neo The One | last post by:
I find some of the Regex classes are quite helpful for my learning. For example: System.Web.RegularExpressions.SimpleDirectiveRege...
0
by: Vikram | last post by:
I am using regex class in codebehind to validate some control's text. But for checking , postback is done.I want to avoid postback and check the same exprseeion using regularexpressionvalidator. I...
0
by: Jim Duffie | last post by:
Hi, I am trying to build a simple websire using the above in Visual Web Developer. When finished I have build the website and it works fine locally but when I FTP it to the server I am getting a...
2
by: AnalogKid17 | last post by:
Keywords: ASP.NET app with VS2005 running on Win2003 with IIS6, and SQL2000 on a WinXP Box I've betting the following for days... it's driving me insane: Server Error in '/' Application. ...
9
by: Arpan | last post by:
If I am not wrong, System.IO is one of the seven namespaces that get imported in all ASP.NET page automatically but in the following code: <%@ Import Namespace="System.IO" %> <script...
9
by: garyusenet | last post by:
I am using a C# solution that somebody kindly sent me. It was a console application. I am trying to get use of the MessageBox. I have added the following using directive to the namespaces at...
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:
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
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: 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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
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.