如何忽略正则表达式中的大小写?

发布于 2024-07-12 03:15:52 字数 207 浏览 5 评论 0原文

我有一个 ASP.NET RegularExpressionValidator 来检查文件扩展名。 有没有一种快速方法可以告诉它忽略扩展名的大小写,而不必显式地将大写变体添加到我的验证表达式中?

ValidationExpression="([^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ... 

I have an ASP.NET RegularExpressionValidator that checks file extensions. Is there a quick way I can tell it to ignore the case of the extension without having to explicitly add the upper case variants to my validation expression?

ValidationExpression="([^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ... 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

離人涙 2024-07-19 03:15:52

在服务器端,可以使用“(?i)”,但这在客户端不起作用。 请参阅此处< /a> 了解更多讨论和解决方法。

即“...(?i)(jpg|jpeg|gif|png|wpf|...”

Server-side, "(?i)" can be used, but this doesn't work client-side. See here for more discussion and workaround.

i.e. "...(?i)(jpg|jpeg|gif|png|wpf|..."

触ぅ动初心 2024-07-19 03:15:52

在 VisualBasic.NET 中,您可以使用 RegExOptions 来忽略大小写:

Dim RegexObj As New Regex("([^.]+[.](jpg|jpeg|gif))", RegexOptions.IgnoreCase)

In VisualBasic.NET, you can use the RegExOptions to ignore he case:

Dim RegexObj As New Regex("([^.]+[.](jpg|jpeg|gif))", RegexOptions.IgnoreCase)
花桑 2024-07-19 03:15:52

根据正则表达式选项,这应该有效:

// Added LowerCase i:
ValidationExpression="(?i:[^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ...

According to the Regular Expression Options, this should work:

// Added LowerCase i:
ValidationExpression="(?i:[^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文