1

I am trying to build a regex in C# code that checks if an input text contains either Greek or English but not both at the same time like the following example:

Angela = true
Ανγκελα = true
AngeΛα = false
Αντζela = false

I have tried the following with no luck:

[a-zA-Z\s]?[α-ωΑ-Ω\s]
[a-zA-Z\s]|[α-ωΑ-Ω\s]

some more info

tripleee
  • 158,107
  • 27
  • 234
  • 292
Zach Ioannou
  • 426
  • 1
  • 6
  • 14

1 Answers1

1

Taking into account the sample input provided in the question, you can use

^(?:[a-zA-Z]+|[α-ωΑ-Ω]+)$

Details

  • ^ - start of string
  • (?:[a-zA-Z]+|[α-ωΑ-Ω]+) - either one or more ASCII letters or one or more Greek letters
  • $ - end of string.
Wiktor Stribiżew
  • 561,645
  • 34
  • 376
  • 476