realbasic-nug
[Top] [All Lists]

Re: regex question: matches only once

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: regex question: matches only once
From: vvor <vvor at jesuschrysler dot com>
Date: Tue, 28 Feb 2006 22:27:29 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <050C6E13-0657-4023-BAD3-8FC3AEE4DE7A at jesuschrysler dot com> <5d8b04c3eb4e43c9306e41e3b7437193 at pp dot inet dot fi> <7A497D57-159A-4E50-9CC6-077DB84D767D at jesuschrysler dot com> <eb8fc1930602252352g31760168m2b798ca094a6208c at mail dot gmail dot com>
this helps awesomely!
except - how do i replace in place the original strinput? do i keep a position counter? do you have a simple example of that, and then i promise i won't bother anybody.
i tried it with a counter, and i'm failing:

strinput = rm.replace(replacementpattern, positioncounter)

and everything gets offset in weird ways.

:(

-vv

On Feb 26, 2006, at 2:52 AM, dda wrote:

Do it in a loop:

Dim rm As RegexMatch
rm=r.search(strinput)
while rm<>Nil
  <do whatever you have to do>
rm=r.search(strinput,rm.SubExpressionStartB(0)+LenB (rm.SubExpressionString(0)))
wend

HTH

--
dda
libcurl4RB, [S]FTP transfers made easy
http://sungnyemun.org/?q=node/8

RBDeveloper Columnist, "Beyond the Limits"
http://rbdeveloper.com

On 2/26/06, vvor <vvor at jesuschrysler dot com> wrote:
thank you, this works. but what if i need access to $1, $2, etc.,
outside of the r.replace? i'd like to process the replacement pattern
a bit based on conditions prior to the replacement. this is done with
regexmatch, yes? but that only matches once?

iow, i want to remember if i match a certain thing so i can alert
other code so that i can influence my replacement patterns a bit.

sorry if i'm dense.

-vv
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>