Serious applications

A.C.T. albrecht at act-net.com
Wed Feb 25 14:50:23 EST 2004


Hi, Rob,

> What is the regular expression to replicate the functionality of "get 
> word 3 of item 6 of line 17 of someText"?

I'd have to ask my regexp specialist. I am a project manager and regexp 
is not my personal hobby ;-)) Besides: regular expressions are handled 
differently in different languages.
But trying to answer the question: "Words" are usually easy to detect, 
every regexp transcription has got a terminus for words (including 
"real" words that are stopped by punctuation etc). "Item" would have to 
be defined, as to my understanding it could be anything from paragraph 
to sentence to page. Line again could be interpreted as "between two 
linefeeds" - or "between two carriage returns" - or "according to the 
current margin settings at a give font size with the registered 
kerning". In the area where I work these components always are of 
importance, a "line" is seldom a "line" ;-) In Regexp I would expect a 
terminus that simply COUNTS the delimiters: Linefeeds being the first 
delimiters (16 being skipped), item is unknown right now, but words 
would then be the next delimiter, so the regexp could look like 
"[\n*16][~2]~" (that's NOT a real regexp, that's just trying to "draw" 
what it would look like!)

> put 0 into word3Total
> repeat for each line theValues in someText
>     add word 3 of item 6 of theValues to word3Total
> end repeat

I feel like having to defend other languages - why?
If I knew what an "item" was in this place I could try to answer it. 
What about - taking PHP for a change - something like this?
$theValues=explode("\n",$someText);
// splitting lines into array "theValues"
$word3Total="";
// clearing word3Total (not necessary, though)
for($i=0;$i<count($theValues);$i++) {
// looping until last line is reached
	$word=explode(" ",$theValues[$i]);
// splitting each line, taken from array, into words, delimited by
// spaces
	$word3Total.=$word[2];
// concating word3Total with word number 3
	}

No - I am not saying this is "beautiful", I am not saying it is 
"perfect". But I _am_ saying that every C, C++, Java, PHP, Shellscript 
programmer will be able to understand it - and improve it. And that's 
what we are talking about: Not limiting code development to a small 
number of coders by using a non-standard programming language.

Marc Albrecht
A.C.T. / Level-2
Glinder Str. 2
27432 Ebersdorf
Deutschland
Tel. (+49) (0)4765-830060
Fax. (+49) (0)4765-830064


More information about the use-livecode mailing list