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

C# Regex Match Evaluator issue

1
I'm attempting to write some code to make all the tags in my webapp lowercase.

Currently I'm using a regex pattern with a match evaluator to do this, but it's not working and gives me some strange errors.

Okay, here's my regex pattern (which works):
Expand|Select|Wrap|Line Numbers
  1. builder = new StringBuilder(Regex.Replace(builder.ToString(),@"(?<=<)[/]{0,1}\w+[^>]",new MatchEvaluator(ToLowerEval)));
  2.  
Now here's the match evaluator:
Expand|Select|Wrap|Line Numbers
  1. private static String ToLowerEval(Match m)
  2.       {
  3.          string match =  m.Value;
  4.          return match.ToLower();
  5.       }
This fails silently, but when I step through with Visual Studio and use the Immediate Command area, I get this:

match.ToLower()
error: 'match.ToLower' does not exist

This happens when I use any of the String functions. Any one know why or have a better way of solving this?
Aug 8 '07 #1
1 4234
I'm attempting to write some code to make all the tags in my webapp lowercase.

Currently I'm using a regex pattern with a match evaluator to do this, but it's not working and gives me some strange errors.

Okay, here's my regex pattern (which works):
Expand|Select|Wrap|Line Numbers
  1. builder = new StringBuilder(Regex.Replace(builder.ToString(),@"(?<=<)[/]{0,1}\w+[^>]",new MatchEvaluator(ToLowerEval)));
  2.  
Now here's the match evaluator:
Expand|Select|Wrap|Line Numbers
  1. private static String ToLowerEval(Match m)
  2.       {
  3.          string match =  m.Value;
  4.          return match.ToLower();
  5.       }
This fails silently, but when I step through with Visual Studio and use the Immediate Command area, I get this:

match.ToLower()
error: 'match.ToLower' does not exist

This happens when I use any of the String functions. Any one know why or have a better way of solving this?
Dear i dont know C# this code on vb.net so i think may be this is help ull to you so try this
Dim SpCharReg As Regex
SpCharReg = New Regex("^[^!#$%^&*(]+$")/////here put ur Regular expressin whatever urs
Dim SpChar As Match = SpCharReg.Match(txtname.Text)///here give the comarision string whatever u want
If Not SpChar.Success Then
Me.lblMessage.Text = "uke lgh Mkys"/// here mesg what ever u want to print
Exit Sub
End If
Aug 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jon Maz | last post by:
Hi All, Am getting frustrated trying to port the following (pretty simple) function to CSharp. The problem is that I'm lousy at Regular Expressions.... //from...
8
by: rjb | last post by:
Hi! Could somebody have a look and help me to optimize the code below. It may look like very bad way of coding, but this stuff is very, very new for me. I've included just few lines. Regex...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
5
by: Greg Collins [InfoPath MVP] | last post by:
I couldn't find anything in my searches... I'm wondering if there's a Regex (with or without additional C# code) that can convert a either "lowerCamelCase" or "UpperCamelCase" into a proper "Title...
7
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not...
1
by: rh | last post by:
hi all, take the following 2 c# lines: 1) str = Regex.Replace(str, ".*AAA", ""); 2) str = Regex.Replace(str, "^.*AAA", ""); notice that the only difference is that the pattern in line 2 has a...
10
by: igor.kulkin | last post by:
I have a small utility program written in Python which works pretty slow so I've decided to implement it in C. I did some benchmarking of Python's code performance. One of the parts of the program...
2
by: O.B. | last post by:
In the following example, the Matches operation never returns 4 matches as I am expecting. What's wrong with my syntax? private const string DOUBLE_REGEX = @"?*?*"; private const string...
0
by: Frenz | last post by:
Hi, I'm facing a performance issue with the following code: MatchCollection match = regex.Matches(strInput); int i = match.Count; //This line is consuming 98% of CPU time for(int...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...

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.