Thanks Jim!
I could not get your solution to work with Rob's plugin, but it works
perfectly with the Regex component which I found on the Forum - here's the
link if anybody needs it:

http://forums.4d.com/Post/EN/7161740/1/7161741

My test code:

$source:="Some text.<span class='bold'>Set this text in bold please
.</span>"

$Srchstring:="<span class='bold'>([^<]*)</span>"

$replacestring:="<@bold:>\\1<@:>"

 $err:=*Rgx_SubstituteText* ($Srchstring;$replacestring;->$source)



Pat



On Sun, 25 Nov 2018 at 03:34, Jim Crate via 4D_Tech <[email protected]>
wrote:

> On Nov 24, 2018, at 9:39 AM, Pat Bensky via 4D_Tech <[email protected]>
> wrote:
> >
> > I'm attempting to use the Regex Plugin from Pluggers to replace tags
> with different tags.
> > For example, change this text:
> >
> > Some text.<span class='bold'>Set this text in bold please .</span>
> >
> > to
> >
> > Some text.<@bold:>Set this text in bold please .<@:>
> >
> > In other words, there' a starting and ending tag with any kind if text in
> > between.
> >
> > I've tried:
> >
> > $Srchstring:="<span class='bold'>[A-Za-z_0-9]</span>"
> >
> > $replacestring:="@bold:[A-Za-z_0-9]<@:>"
> >
> > $t:=*Preg Replace*($Srchstring;$replacestring;$source)
>
> I didn’t download Rob’s plugin to check the manual, but regex replacing
> works by using capture groups in the regex that the replace string
> references. You’ll need to check the plugin manual for specifics, or the
> example database. Capture groups are usually indicated with parenthesis,
> and the references are usually \1, \2, etc, based on the order of
> appearance of capture groups in the pattern. Sometimes they’re referenced
> with $ instead of \.  So it could be something like:
>
> $SrchString:="<span class=‘bold’>([^<]*)</span>"
> $ReplaceString:=“<@bold:>\\1<@:>”
>
> I used [^<] because that will match any characters except <, so it’s more
> concise than listing all the acceptable characters, and also expresses the
> intent better. If you have nested tags it won’t work, but I’m not sure if
> nested tags can be handled with a simple regex pattern.
>
> The backslash reference in the replace string will probably have to be a
> double-backslash. Because double backslashes is annoying, Rob might have
> used a different referencing scheme. You’ll want to check the manual.
>
>
> Jim Crate
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************



-- 
*************************************************
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to