[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [StrongED] Feature suggestion/request



In message <8906fa6f51.martin@xxxxxxxxxxxxxxxx>
          Martin Bazley <martin.bazley@xxxxxxxxxxxxxxxx> wrote:

> The following bytes were arranged on 1 Nov 2010 by Fred Graute :
>
> > > I bet it doesn't work, though - IME the ~ modifier is hideously
> > > unreliable.  (In fact, I'd been meaning to post on that subject, but
> > > kept forgetting.)
> >
> > The ~ operator is not unreliable IMO but it is tricky to get expressions
> > that use it to work as desired. If you have any evidence that ~ is not
> > working correctly then I'd be interested to hear about it.
>
> Well, this one (as I hypothesised) didn't work, for example:
>
> Replace("(~\x0D)\x0A\x0D","\l",text,noline,nocase)
>
> When presented with a string of 0D0A 0D0A 0D0A, it simply treated it as
> two 0A0Ds with a leading 0D and trailing 0A.  The first 0D, and the
> third, were supposed to have returned an invalid match.  What went
> wrong?

It would seem that you are misunderstanding how ~ works.

When the search expression ismatched against the string 0D0A 0D0A 0D0A
the following happens:

 - ~\x0D is matched against 0D, this fails so the matching stops and
   StrongED moves to the next character in the string, ie 0A

 - Matching ~\x0D against 0A succeeds as does the rest of the search
   expression so the replacement is made.

 - The search continues after the replacement string. If * is the
   replacement string then the situation now looks like this:
   0D*0A 0D0A
      ^ matching continues here

 - The match at the continuation point succeeds so another replacement
   is made. resulting in 0D**0A.

 - The next match fails as there's only a single 0A left.

Hopefully this clarifies how ~ works. If not, then don't hesitate to ask
further questions.

Cheers,

Fred.

-- 
StrongED developer
http://www.stronged.iconbar.com/

-- 
To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxxxxx