... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2007-12-19

Ecmascript RegExp

Here are a couple of fine points about Ecmascript regular expressions worth noting.

The '.' atom does not match the four line terminator characters LF, CR, LS, and PS.  This is true irrespective of the presence of the multiline flag in the expression.

You indicate that a quantifier should be non-greedy by suffixing the pattern with '?'.  For example, '.*?', '.+?', '.??' etc.

These points are true for most other regular expression implementations as well.


2007-12-17

WScript vs. ERRORLEVEL

If you invoke a Windows script directly from a command prompt, it will be launched using WScript and its exit status (set using WScript.Quit) will be gobbled.  If you launch it using CScript, the exit status will be returned properly.  Interestingly, if you invoke a script file from within a batch file, CScript is used automatically, despite the default file association to WScript.


2007-12-13

BAT Files vs. Variable Expansion

You might think that the following BAT script would print out the word right:

set answer=wrong
if "a" == "a" (
    set answer=right
    echo %answer%
)

... but it actually prints out wrong.  The reason is that the BAT processor expands the variable answer when it is read, not when it is executed.  To work around this problem, you must use an extension, thus:

setlocal enabledelayedexpansion
set answer=wrong
if "a" == "a" (
    set answer=right
    echo !answer!
)

Note the use of exclamation marks instead of percent signs to delimit the delayed expansion of the variable answer.


2007-12-10

TCPMon

TCPMon has been moved out of the Axis project and into a subproject of its own in the Apache Web Services commons.


Blog Archive