[Oberon] Re: ^2: RX.Tool scope limited to 1 line ?

Chris Glur easlab at absamail.co.za
Tue Mar 27 11:33:51 MEST 2007


Can it replace the multiple lines, starting with the one
containing 'cat' up to the one containing 'dog' ?

Easthope a écrit :
> <anyString> <space> "cat" <anyString>
> <anyString for line 2>
> <anyString for line 3>
> <anyString> <space> "dog"
> 
> ?
> 
> Yes, I expect that Regul can do it ... but I've never 
> tried a similar problem.
_____________________________________
Gérard wrote:
> My last little improvements were made under BlackBox 
> (see Helmut Zinn's site). 
> 
That's why it's not well 'formatted' for N-O ?

> But the latter example works easily under Oberon: in Regul.Panel, 
> write
> 
> 	$ .* cat (.|$)* dog .*
> 
> in the Find: field; write nothing in the Repl.: field; mark (F1) the 
> text that must be changed; press Find Next and, then, Replace. It's all.
> 
> Hint: $ stands for EOL, a dot (.) stands for any character, but not EOL, 
> the star (*) marks the repetition of the previous word, a vertical bar 
> (|) stands for a logical OR and braces group expressions together. Press 
> the Help button and follow the links in the title for further explanations.
> 
> Hint 2: If the first line to be deleted is the first line in the text, 
> without any EOL before, don't write the first $ in the Find: field.
-________________________________________________________________________________

	$ .* cat (.|$)* dog .*
== <EOL>    <-- starts @ EOL/line-boundry
    [any character, but not EOL]repeated  {0?1 times}
    'cat'
    [any character]repeated
    'dog'
    [any character, but not EOL]repeated  <-- terminates @ EOL-boundry
--________________________________________________________________________________
Using my log from 10 June 2004, when I first D/Led the package for 
testing, and had a near nervous breakdown when finding that :
} This package requires the TBox and Babel subsystems
I now find:
*  searched file must be 'gadget' type. ie. not Edit.Open
* [Replace] gives:  TRAP 100  HALT statement TBoxMapping.Init  PC = 888
  if the [Find Next} text-stretch is not fully seen as selected.
  Ie. when the text-stretch size doesn't cause the display to scroll to show
  the end of the selection, then [Replace] is ok.
  Since I've got many 4-line-long-stretches to delete, it can do it.
* the suggested [Find Next] field for my immediate/example[s] is not 
correct, because it finds the biggest text-stretch bracketed by 'cat'
& 'dog'.  Whereas I eg. want to process multiple text-stretches bracketed 
by 'cat & 'dog'.   Analagously if you want to delete all text-stretches 
between "(" and ")" you don't want to delete all of the single 
text-stretch between the first "(" and the last ")".
 
I guess what I need [for this example] is easier that what you've given
me, but I don't want any more school boy exercise new syntaxes to 
learn, so some examples are welcome.  Ie. I seem to remember reading
how Perl is [also] too clever: finding the biggest matching pattern. I just 
want the first/smallest [but repeating] match [for my immediate 
example].

Thanks,

 == Chris Glur.
 
 PS. how would I remove the first 3 spaces ["   "] of each line of a text ?
 


More information about the Oberon mailing list