-2

I want a regular expression to find addresses having mixed characters that can be used in Alteryx. The first example has capital cases in the beginning and second one in between.

  1. IFBDAGE,Place des Augustins 19,Bonita Springs
  2. 28/10 Macquarie Street,NEWSTEAD,Bonita Springs

3 Answers3

0

Don't do it with regular expressions. Make your life easier and use a normal function:

public static string GetUpperCasePart(string address, char delimiter)
{
    foreach (var part in address.Split(delimiter))
    {
        if (part.All(c => Char.IsLetter(c) && Char.IsUpper(c)))
            return part;
    }

    return string.Empty;
}

Working example: https://dotnetfiddle.net/x3NxOJ

Good Night Nerd Pride
  • 8,245
  • 4
  • 49
  • 65
0

In your regex \b[A-Z0-9]{2,}\b why are you using 0-9, if you just use \b[A-Z]{2,}\b, it will give the capital letters in the middle as well.

Anita
  • 1
  • 3
0

assuming that your Strings don´t contain the capitals in upperCase, matching should be difficult... Otherwise, Abbondanza´s solution is working and you can use the RegEx like Anita explained ;)

BingBingBong
  • 88
  • 10