如何搭配普通防爆pression连字符? [英] How to match hyphens with Regular Expression?

查看:112
本文介绍了如何搭配普通防爆pression连字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何重写 [A-ZA-Z0-9!$ * \\ t \\ r \\ n] 模式与现有的字符一起匹配连字符?

How to rewrite the [a-zA-Z0-9!$* \t\r\n] pattern to match hyphen along with the existing characters ?

推荐答案

逃生连字符。

[a-zA-Z0-9!$* \t\r\n\-]

更新:结果
没关系这个答案 - 您可以连字符添加到组,但你不必逃避它。见<一href=\"http://stackoverflow.com/questions/4068629/how-to-match-hyphens-with-regular-ex$p$pssion/4068725#4068725\">Konrad鲁道夫的答案,而不是其中不回答的一个更好的工作,并解释了原因。

UPDATE:
Never mind this answer - you can add the hyphen to the group but you don't have to escape it. See Konrad Rudolph's answer instead which does a much better job of answering and explains why.

这篇关于如何搭配普通防爆pression连字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆