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

Oliver Hader oliver at typo3.org
Fri May 29 09:26:53 CEST 2009


Hi Masi,

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.

In general I agree, but which other methods/strategies can you think to
replace a string? However, I'm fine with having the methods "regexp" and
"string"...

> 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).

The shell freak stuff is just a wrapper for regular expressions. I don't
think this overhead is required.

> Unclear to me is why # (the TS comment sign) is used in this example as
> regexp delimiter.

It's just an example to show that any delimiter can be used. But I agree
that it is confusing in the TSref documentation and should be changed to
slashes '/'.

> 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

Using a delimiter in the search property is mandatory and defining the
delimiter on a additional property is not necessary. The regexp part
here is the TypoScript "bridge" to preg_replace() - and it should be
close to that PHP function.

> 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.

Ok, sounds good - but should be the other way round: "caseless" or
"caseInsensitive" that has to be enabled.

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

It's not a COA, it's a simple array to define the order - similar to
split or imgObjNum on IMGTEXT. But if you don't like it, maybe you have
another idea on that?

olly
-- 
Oliver Hader
TYPO3 Release Manager 4.3


More information about the TYPO3-team-core mailing list