Questions tagged [matchevaluator]
13 questions
57
votes
1 answer
How does MatchEvaluator in Regex.Replace work?
This is the input string 23x * y34x2. I want to insert " * " (star surrounded by whitespaces) after every number followed by letter, and after every letter followed by number. So my output string would look like this: 23 * x * y * 34 * x * 2.
This…

dontoo
- 793
- 1
- 6
- 10
29
votes
4 answers
What is the equivalent of Regex-replace-with-function-evaluation in Java 7?
I'm looking for a very simple way of getting the equivalent of something like the following JavaScript code. That is, for each match I would like to call a certain transformation function and use the result as the replacement value.
var res = "Hello…

user2864740
- 60,010
- 15
- 145
- 220
28
votes
2 answers
How would I pass additional parameters to MatchEvaluator
I have a bit of code that looks like this:
text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff));
I need to pass in a 2nd parameter like this:
text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff, otherData));
Is this possible, and…

Jon Tackabury
- 47,710
- 52
- 130
- 168
8
votes
3 answers
What does this "Lambda Expression" do?
Just come across the following line of code and having a hard time finding documentation for it, is it a lambda expression? What does this do?
temp = Regex.Replace(url, REGEX_COOKIE_REPLACE,match =>…

m.edmondson
- 30,382
- 27
- 123
- 206
5
votes
3 answers
How do you use Regular Expressions to replace a particular match (e.g "last" or "second to last")?
I am trying to replace a single (last or next-to-last) match in a string. I have my Regular Expression already and it works, but it replaces ALL items, then I have to run back through and replace a single item.
Regex.Replace(BaseString,…

jeffreypriebe
- 2,267
- 25
- 30
2
votes
1 answer
How to include separators in the regex match result?
Currently, I am doing search and replace using this pattern:
"(?<=\\{).+?(?=\\})". This finds everything inside curly brackets. (Courtesy of https://stackoverflow.com/a/8526268/1143917)
I use 'MatchEvaluator' with a delegate, so, when the input…

Vlad
- 2,475
- 21
- 32
2
votes
3 answers
How to replace each Capture of a Group individually?
I have a regular expression which uses GroupCollections in it's capture to capture a group of Item Id's (which can be comma separated, also accounting for the final one to have the word 'and'):
(\bItem…

michael
- 14,844
- 28
- 89
- 177
1
vote
2 answers
The Unknown Exception DateTime C#
The data that I am sending to convertStringToDataSet function is
\r\n
\r\n