在字段中使用字符串替换/正则表达式来获取rte字段

I want to cutoff everything but the first paragraph from an rte field for an excerpt:

20 = HTML
20.value.field = tx_myextention_field
20.value.parseFunc < lib.parseFunc_RTE
20.wrap = <p class="claim-long">|</p>
20.stdWrap.replacement {
  10 {
    search = /^(.*?\/p).*$/m
    replace = \1>
    useRegExp = 1
 }
}

Why is this regex not working? Or is there a better solution?

You could use stdWrap.cropHTML to achieve a similar effect. It would also shorten a long first paragraph, and use more than one paragraph, if the first one is too short. But maybe thats desirable in your situation?

Please be aware that the HTML cObject was deprecated in TYPO3 4.6. You should use the TEXT cObject.

I suspect that in your case the parseFunc was not properly applied because stdWrap cannot be used on the value but directly on the object. Without stdWrap, the newlines saved in the database are not transformed to <p> tags and therefore your regex couldn't apply.

I tried to fix your TypoScript (but it is untested):

20 = TEXT
20.field = tx_myextension_field
20.stdWrap.parseFunc < lib.parseFunc_RTE
20.stdWrap.replacement {
  10 {
    search = /^(.*?\/p).*$/m
    replace = \1>
    useRegExp = 1
 }
}
20.wrap = <p class="claim-long">|</p>