Actions
Task #97553
closedIntroduce string fragment extraction
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-05-05
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Sprint Focus:
Description
When working with variable interpolation and similar scenarios, in most cases variables, constants, expressions, ... are embedded in a solid string and can only be identified and extracted by the corresponding "reader" or "parser".
This string fragment splitter aims to introduce a simpler way for extracting and working with these embedded fragments.
$pattern = new StringFragmentPattern( StringFragmentSplitter::TYPE_EXPRESSION, '%[^%]+%' ); $splitter = new StringFragmentSplitter($pattern); $collection = $splitter->split( 'Hello %variable% World!' FLAG_UNMATCHED_AS_NULL | FLAG_CATCH_SPACES ); // results in having // + StringFragment(type: 'raw', value: 'Hello') // + StringFragment(type: 'expression', value: ' %variable% ') // + StringFragment(type: 'raw', value: 'World!')
Actions