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

Martin Kutschker masi-no at spam-typo3.org
Mon Jun 1 18:56:47 CEST 2009


Oliver Hader schrieb:
> 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.

Right, but it *could* be added. I'm only trying to think ahead a bit. It
doesn't hurt to use "method" or "mode" instead of "useRegExp". Maybe it
comes in handy, maybe not. But at least it sets a good example.

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

No real problem though I think the resemblance is superfluous. It all
dates back from Perl where you could use /regexp/options without any
quotes. In PHP it should have been something like match('regexp',
'options') with options being an array or a bitmask. But hey, that's PHP
for you.

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

Right you are.

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

Something like my original idea for the processors of TS in v5. A
"processing array" with all options of stdWrap (of course without the
stupid duplication of the wraps):

foobar = TEXT
foobar {
  value = Lorem Ipsum
  process {
    10.wrap = <b> | </b>
    20.search = e
    20.search.replaceBy = u
    30.wrap = <p> | </p>
  }
}

So you can repeat you replacements any time you like intertwined with
other stdWrap functions.

Masi


More information about the TYPO3-team-core mailing list