Robert Fish wrote:
> Hi Ninjas,

Hi, um, Fish.

> I am a new HOF user who has lurked here, and benefited from much knowledge
> in the past... and I am in a bit of a pickle.

1 good and 1 bad.  Breaking even so far.

> Sample string:
> Dear #GetNames.FirstName#,<BR>Thank you for purchasing #GetNames.Quantity#
> widgets on
> #DateFormat(Now(),"dd/mm/yy")#.<BR>Sincerely,#GetNames.ContactPerson#
>
> "Dear " & #GetNames.FirstName#&",<BR>Thank you for purchasing " &
> #GetNames.Quantity# & "widgets on " & #DateFormat(Now(),'dd/mm/yy')# &".
> <BR>Sincerely," & #GetNames.ContactPerson#
>
> I wanted to just replace every other occurance of a # character with " &
> and
> then somehow the closing # chars with & " to build the new string for
> output.
>
> My question... can RegEx do something like this in a loop, where it finds
> the first occurance of a # char, replaces it with X and then goes on to
> find
> the next occurance and replaces it with Y and then finds the next occurance
> and replaces it with X and the next with Y and so on??

Sort of.  You'd actually do both replaces simultaneously:

rereplace("##([^#])##", '"&##\1##&"', "all")

> Thank you for any help you can provide.  I will be eagerly awaiting a reply.

You are quite welcome.  It's not been tested, but should work fine,
provided you don't have any stray hashes in your string.  If you need
more help (or if I screwed up and it doesn't work) feel free to ask.

--Ben
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to