Typoscript - Use regex replace on field value

时间:2017-04-08 22:28:26

标签: regex typo3 typoscript

A part of a COA I have gets the page title. What I would like to do is replace the space between the last two words with a  

But adding the stdWrap.replacement part results in no output at all:

stdWrap.cObject = COA
stdWrap.cObject {
  10 = TEXT
  10.field = title
  10.htmlSpecialChars = 1
  10.wrap = <h2>|</h2>
  10.stdWrap.replacement {
    10 {
      search = \s(\S+)$
      replace = &nbsp;\1
      useRegExp = 1
    }
  }
}

1 个答案:

答案 0 :(得分:2)

查看Typo3 replacement docs

10 {
  search = #(a )CAT#i
  replace = \1cat
  useRegExp = 1
}

#中的#(a )CAT#iregex delimiters。所以,你需要的只是提供任何,比如说:

search = /\s(\S+)$/