Path: news.cs.au.dk!not-for-mail From: "Jorgen Lindskov Knudsen" Newsgroups: comp.lang.beta Subject: Re: REGEXP not doing anything! Date: Thu, 10 Jun 1999 10:17:01 +0200 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 70 Message-ID: <7jns9t$46qjk$1@xinwen.cs.au.dk> References: <19990610073958.20891.qmail@noatun.mjolner.dk> NNTP-Posting-Host: corona.cs.au.dk X-Trace: xinwen.cs.au.dk 929002621 4418164 255.255.255.255 (10 Jun 1999 08:17:01 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 10 Jun 1999 08:17:01 GMT X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Xref: news.cs.au.dk comp.lang.beta:11987 You have made the same bug in both examples. The problem is not relatet to regexp, but the fact, that text variables in BETA contains the notion of position within the text, and most text operations work 'from the current position' in the text. When texts are initialized by statements like: 'Hello world'->t[] then the position will be at the very end of the text, and the following regexp_replace operation will try to replace in the string from that position - since thaat is at the end of the string, no match will be found (and the noMatch virtual will in fact be invoked). In your examples, just insert t.reset as in: 'Hello world'->t[]; t.reset than everything will work as you expect. Regards, Jørgen Lindskov Knudsen Sascha Kimmel wrote in message <19990610073958.20891.qmail@noatun.mjolner.dk>... >Hi! > >I want to use the regexp fragment for parsing purposes, but even your >simplest demo program (p. 86 in mia90-08.pdf) does not work with BETA >4.1: > >ORIGIN '~beta/basiclib/v1.6/betaenv'; >INCLUDE '~beta/basiclib/v1.6/regexp'; > >-- program: descriptor -- > >(# > t:^text; > do > 'Hello world' -> t[]; > ('\\', '\\0 champion') -> t.regexp_replace; > t[] -> putline; (* prints 'Hello world champion' *) >#) > > >This program just produces a "Hello world" and not "Hello world >champion". >The very very simple > >ORIGIN '~beta/basiclib/v1.6/betaenv'; >INCLUDE '~beta/basiclib/v1.6/regexp'; > >-- program: descriptor -- > >(# > t:^text; > do > 'Hello BETA!' -> t[]; > ('BETA', 'Mjolner') -> t.regexp_replace; > t[] -> putline; (* should print 'Hello Mjolner!' *) >#) > >only gives me a "Hello BETA!" and not the string that should be there. > >Is the regexp fragment working in some way? > >Any quick help is appreciated. > >Regards, >Sascha Kimmel >