In fact you know what.. instead of using regular expressions, you might as well just ship the freepascal compiler with your application (buried in a DLL or .SO file or something) and write PascalObfuscations.
Compile the PascalObfuscations on the fly.. and then use them immediately. For example.. this program will work for you and it is only one line!!!! (note how many exclamation marks I used in the previous sentence) program Project1; {$mode objfpc}{$H+} {$define Z:= begin } //note: the defines could be kept in an include file {$define X:= end } {$define Y:= procedure } {$define A:= for } {$define B:= to } {$define C:= do } {$define D:= writeln } {$define E:= var } {$define F:= := } {$define G:= : } {$define H:= ; } {$define I:= . } {$define J:= integer } {$define K:= iLoc } {$define L:= testing1 } e k g j h Y l h Z a k f 1 b 60 c d('test') h X h Z l h X I Reminds me of something you see in a spam message. Now we could actually stop playing games and do something useful though. Seriously, this is similar to a regular expression... just that regular expressions were thought out properly, and the above program -was not-.You could actually make something useful out of this, if the defines were thought out properly, and the situation fit the need. There are those situations where regex's come handy because they are quick and dirty, and they work in real time environments when you just don't have time to write a real search and replace algorithm. In text editors for example, or in web applications.. people do in fact use regexes. Non-programmers do to. In Excel spreadsheet, people use a shortform language basically... because who has time to write an entire program, just to get data out of Cell A1 and Cell A2? In Excel, =A1&A2 is basically just a shortform for the programming language behind the scenes, if you think about it We might even be able to turn the whole Pascal language into one regex-like looking thing, or Excel-like looking thing, as just purely an OPTION for those times when you need quick syntax. So people could write PascalEx's or PasExcels instead of regexes. Particularly if some standards were set. We can't have each person writing their own define macros.. but if we had some standards.. and some standard Define files which people could download... Don't laugh at it all though..... I use regexes, and they are useful.. I'm serious about this. It's just a matter of figuring out -where- this situation could be most useful. Someone found a useful situation for regexes, and they work. Someone found a useful situation for Excel language, and it worked. But surely there are other situations.. Sometimes I find that regexes limit me in some ways or that regex's are not the answer for some problems... or that regexes are way too slow. Maybe there is an opportunity in those particular cases. Or maybe a solution which has nothing to do with search and replace. Remember, someone might have laughed at regexes too, when they were first thought up. Another idea would be to allow users to make Rapid plugins for your application. Using a shortform syntax, users would be more inclined to write a DLL or .SO plugin for your applications (think like total commander plug-ins). I know larger plugins for applications require time and thinking. so the syntax is really not an issue. But for those situations where you are writing a small plug in for the application, something like a regex syntax might be useful. Remember, in Excel, no one wants to write an entire begin/end program just to get A1 Cell data into B2 Cell data. Since the Pascal compiler is so fast, you could pretty much pretend you were writing a script for your program.. then have the program save your so called script. (think like Microsoft's VBA). Instead of using Java or something, or VBA, you'd just compile your so called "scripts" with the Pascal compiler.. on the fly. Once they were compiled, they'd be "saved" as a "macro" (think like VBA macros). Anyone see all the overwhelming opportunities that I see? I know I sound like I'm on crack, but I'm not. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal