The Old New Thing

How do I write a regular expression that matches an IPv4 dotted address?

Writing a regular expression that matches an IPv4 dotted address is eithereasy or hard, depending on how good a job you want to do.In fact, to make things easier, let's match only the decimaldotted notation, leaving out the hexadecimal variant,as well as the non-dotted variants.For the purpose of this discussion,I'll restrict myself ...
Comments are closed.0 0
Code

Redirecting output can result in altered program behavior

Consider a program whose output to the console goes like this.(I've prefixed each line with the output stream.)You want to capture both the normal and error streams,so you run the program and append">output 2>&1" to capture both streamsinto a single file.But when you look at the resulting output file, you get this:What ...
Comments are closed.0 0
Code

Making up new Winter Olympic events

My approach to inventing new Winter Olympic events is to create new opportunities for head-to-head competition, opening the door to new dramatic possibilities. For example, in Ski Jump Biathlon, one team jumps while the other team tries to shoot them (with paint pellets, of course) as they sail through the air. In Figure Curling, one team ...

The redirection operator can occur in the middle of the command line

Although the redirection operator traditionally appears at the endof a command line, there is no requirement that it do so.All of these commands are equivalent:All of them echo "A B" to the file "C".You can use this trick to avoidthe redirection problem we discussed last time.We saw that writinginadvertently interprets the "2...

Beware of digits before the redirection operator

If you want to put the string "Meet at 2" into the file "schedule",you might be tempted to useIf you try this, however, you'll see the string "Meet at" on thescreen and the "schedule" file will be blank.[Typo fixed, 10am]What happened?A digit immediately before a redirection operator modifieswhich stream the redirection operator...

Command line redirection is performed by the command line interpreter

The magic characters like<,>, and|in command lines likeare interpreted by the command interpreter CMD.EXE;they aren't built into the CreateProcess function.(This is obvious if you think about it.That command line created two processes; which one shouldCreateProcess return a handle to?)If you pass a command line like this ...

The first word on the command line is the program name only by convention

The format of the command line returned by GetCommandLine is "program args", but this is only a convention. If you pass NULL for the lpApplicationName to the CreateProcess function, then the CreateProcess function will treat the first word of the lpCommandLine as the program name. However, if you pass a value for lpApplicationName, then that ...