Regex's in JScript.NET
I started reading JScript.NET Programming today:
This language offers a very different way to write .NET code. I'm reading it mostly for two reasons, A) I like the authors' manner of offering more abstract samples and sensible advice than you tend to get in a book of this size; B) so that I can learn about how Regular Expressions are implemented within the JScript.NET language. I'm keen to write a dirt simple regex based routine using to lex through a string with multiple regex's within a loop similar to how you might do it using Perl; it might be nice if you could write and compile regex parsing routines in a js module and consume it from an other language of choice.
So, anyway, I started on Chapter 12 : Regular Expressions and wrote my first app. with it tonight...
import System ; function DoMatch( str ) { var re = /\w+/g ; while( re.test( str ) ) { Console.WriteLine( RegExp.index + " - " + RegExp.lastIndex + "\t" + RegExp.lastMatch + "." ) ; } } DoMatch( "This is a group of words" ) ;
C:\>jsc /t:exe /fast- JS_One.js Microsoft (R) JScript .NET Compiler version 7.10.3052 for Microsoft (R) .NET Framework version 1.1.4322 Copyright (C) Microsoft Corporation 1996-2002. All rights reserved. C:\>JS_One 0 - 4 This. 5 - 7 is. 8 - 9 a. 10 - 15 group. 16 - 18 of. 19 - 24 words.