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
  • 175,061
  • 34
  • 275
  • 318
Zach Ioannou
  • 656
  • 2
  • 8
  • 19

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
  • 607,720
  • 39
  • 448
  • 563