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 (5)

  1. says:

    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. 🙂

  2. ericgu says:

    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…

  3. Maurits says:

    .*? is one of the few things to stay the same in Larry Wall’s retooling of Perl’s regexen for Perl 6:

  4. S says:

    ?: 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…


Skip to main content