[TYPO3-core] RFC Feature #9373: Integrate string replacement to stdWrap

Steffen Kamper info at sk-typo3.de
Fri May 29 00:25:59 CEST 2009


Hi olly,

i like the idea very much! This would make it possible to replace marker 
or other stuff in any content with TS, very useful!

I started with the documentation, and i have one comment, that tsRef 
shouldn't be coders stuff. \1, preg_replace(), str_replace() is not 
understandable for non php-coders, and i would merge description to show 
that there are objects (COA) with single replacement actions, some 
examples are the most clear way. Sure the regexp-method could be more 
technical.

Martin Kutschker schrieb:
> Oliver Hader schrieb:
>>    30.search = #a (Cat|Dog|Tiger)#i
>>    30.replace = an animal
>>    30.useRegExp = 1
> 
> Don't use a boolean configuration. Imagine you wanted to add a new
> "mode" then you have the same troubles as we have so often. Either
> useRegExp turns suddenly into a string like useRegExp=newmode or we add
> a useNewMode=1 which clashes with useRegExp=1.
> 
> So the IMHO proper way is to have "method" or "mode" property which
> defaults to "string", but could be also either "regexp" or "wildcard" (?
> and * for shell freaks).
> 
> Unclear to me is why # (the TS comment sign) is used in this example as
> regexp delimiter.
> 
> The regexp options
> 
>     30.search = #a (Cat|Dog|Tiger)#
>     30.replace = an animal
>     30.method = regexp
>     30.delimiter = #
>     30.caseSensitive = 1
> 
> The delimiters are optional:
> 
>     30.search = a (Cat|Dog|Tiger)
>     30.replace = an animal
>     30.method = regexp
> 
> Note that caseSensitive may IMHO be a boolean option as I cannot think
> of any way how this could be not a simple yes/no question.
> 
> It is a property on its own, because also other search mode could be
> case insensitive.
>

very nice comment. i also want the possibility to use full qualified 
patterns inclusive modifiers. IIRC the BE sarch with repgexp works in 
same manner, something like
30.search = /(\w+) (\d+), (\d+)/i
30.replace = ${1}1,$3
30.method = regexp
30.method {
	delimiter =
	modifier =
}

default modifier should be i, so case sensitive would be setting to empty.

> Masi
> 
> PS: Although it is nice that the replace is a COA it's not quite in line
> with the rest of stdWrap.

why ? With this method you can place a special replacement after one 
replacement, so COA syntax makes sense.

sry for commenting before looking to the patch.

vg Steffen


More information about the TYPO3-team-core mailing list