【问题标题】:Powershell: How to detect if a string contains Hebrew letters?Powershell:如何检测字符串是否包含希伯来字母?
【发布时间】:2022-01-26 19:32:52
【问题描述】:

我需要检测给定的文件名是否包含任何希伯来字母。 (基本上,我的文件管理代码只需要对文件名中包含希伯来语的文件进行操作。)

Powershell 会如何检测文件名中是否有希伯来字母? (或者,我想,在任何字符串中)。

(FWIW 我在 Windows10 上)

【问题讨论】:

  • 您好,我认为link 中的答案就是您想要的。

标签: powershell


【解决方案1】:

作为Abraham Zinala points out in the comments,您可以通过描述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

【讨论】:

  • 谢谢,非常接近我的构建。不需要变音符号,只需要字母(主要字符,例如 [\u0590-\u05ea]
猜你喜欢
  • 1970-01-01
  • 2020-12-12
  • 1970-01-01
  • 2015-01-04
  • 2012-05-16
  • 1970-01-01
  • 2011-07-11
  • 1970-01-01
相关资源
最近更新 更多