如何在cmd中输入特殊字符? [英] How to input special character in cmd?
问题描述
我写了一个c程序,从Windows下的命令行检索参数。其中一个参数是正则表达式。所以我需要检索特殊字符,如(,。等,但cmd.exe处理(作为一个特殊字符。
I have written a c program that retrieves arguments from the command line under Windows. One of the arguments is a regular expression. So I need to retrieve special characters such as "( , .", etc., but cmd.exe treats "(" as a special character.
这些特殊字符?
感谢。
推荐答案
myprogram.exe "(this is some text, with special characters.)"
虽然我不会假设括号会导致问题,除非你使用块作为条件语句或循环通常由shell进行处理并需要引用或转义的字符数组是:
Though I wouldn't assume that parentheses cause problems unless you are using blocks for conditional statements or loops in a batch file. The usual array of characters that are treated specially by the shell and need quoting or escaping are:
& | > < ^
如果在正则表达式中使用这些,转义这些字符:
If you use those in your regular expression, then you need quotes, or escape those characters:
myprogram "(.*)|[a-f]+"
myprogram (.*)^|[a-f]+
( ^
,这会导致下面的字符不被shell解释,而是逐字地使用)
(^
is the escape character which causes the following character to be not interpreted by the shell but instead used literally)
这篇关于如何在cmd中输入特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!