How to enter a special character in cmd?

I wrote a c program that extracts arguments from the command line under Windows. One argument is regular expression. Therefore, I need to get special characters such as "(,." Etc., but cmd.exe treats "(" as a special character.

How can I enter this special character?

thank.

+5
shell cmd
Nov 16 '09 at 11:17
source share
2 answers

You can put the arguments in quotation marks:

myprogram.exe "(this is some text, with special characters.)" 

Although I would not suggest that parentheses cause problems if you do not use blocks for conditional statements or loops in a batch file. The usual array of characters specially processed by the shell and need to be quoted or escaped:

 & | > < ^ 

If you use them in your regular expression, you need quotes or avoid these characters:

 myprogram "(.*)|[af]+" myprogram (.*)^|[af]+ 

( ^ is an escape character that results in the next character not being interpreted by the shell, but used literally)

+8
Nov 16 '09 at 11:18
source share

You can usually prefix any ^ character to disable its special character. For example:

 Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\Pax>echo No ^<redirection^> here and can also do ^ More? multi-line, ^(parentheses^) and ^^ itself No <redirection> here and can also do multi-line, (parentheses) and ^ itself C:\Documents and Settings\Pax> 

This is the carriage followed by the ENTER after the word do .

+9
Nov 16 '09 at 11:18
source share



All Articles