0

I need to detect if a given filename contains any Hebrew letters. (Basically, my file management code needs to operate only on files that have Hebrew in the filename.)

What would the Powershell look like to detect if there are Hebrew letters in a file name? (or, I suppose, in any string).

(FWIW I am on Windows10)

Jonesome Reinstate Monica
  • 6,618
  • 11
  • 65
  • 112

1 Answers1

2

As Abraham Zinala points out in the comments, you could test for whether any characters in a given string is matched by describing the appropriate unicode ranges of Hebrew characters and diacritics:

PS ~> "No hebrew here" -match '[\u0590-\u05FE\uFB1D-\uFB4F]'
False
PS ~> "עִבְרִית‎" -match '[\u0590-\u05FE\uFB1D-\uFB4F]'
True
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206