-3

I need a regex pattern that accepts words but if the words contains underscore / dashes or number it is not valid so:

Word ---> good
Word1.0 ---> no
word_1 ---> no
JPhillips
  • 59
  • 1
  • 5

1 Answers1

0

Use

\A[\p{L}\p{M}]+\z

In C#:

var result = Regex.IsMatch(input, @"\A[\p{L}\p{M}]+\z");

Details:

  • \A - start of string (replace with (?![\p{M}\p{L}]) if partial match is required)
  • [\p{L}\p{M}]+ - 1 or more letters or diacritic characters
  • \z - the very end of the string.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563