Regex 101 Discussion I7 - Make sure all characters inside <> are uppercase
Regex 101 Exercise I7 - Make sure all characters inside <> are uppercase
First, as Sheva pointed out, making them all *lowercase* would make a lot more sense, but you have probably noticed that the correlation between these exercises and making sense is tenuous at best.
This is another case where that MatchEvaluator functionality is so useful. To match inside the <>, we simply use:
<.*?>
(Extra Credit: Discuss why the "?" is required, what other options are available, and the relation between the different match options and Adam Smith's market theories.)
Then, our MatchEvaluator is as follows:
static public string Evaluator(Match match)
{
return match.Groups[0].Value.ToUpper();
}
Comments
- Anonymous
February 10, 2006
You weren't kidding about the tenuous making sense connection! I'm utterly stumped as to what regex's have to do with Adam Smith's Wealth of Nations. :-) - Anonymous
February 10, 2006
A little hint...
In the regex, I used the '?' character, which has a specific meaning. It changes the operation of the regex engine from <X> to <Y>.
Both <X> and <Y> are the answer to your question... - Anonymous
February 13, 2006
.*? is one of the few things to stay the same in Larry Wall's retooling of Perl's regexen for Perl 6:
http://dev.perl.org/perl6/doc/design/apo/A05.html - Anonymous
February 14, 2006
?: By default regexes are greedy i.e. they'll try to match as much as they can, adding a ? makes the regex non-greedy with a 0 or 1 match.
hope i was correct...
S - Anonymous
June 08, 2009
PingBack from http://quickdietsite.info/story.php?id=3495