[TASK] Introduce string fragment extraction
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. Example: $pattern = new StringFragmentPattern( StringFragmentSplitter::TYPE_EXPRESSION, '%[^%]+%' ); $splitter = new StringFragmentSplitter($pattern); $collection = $splitter->split( 'Hello %variable% World!' FLAG_UNMATCHED_AS_NULL ); // results in having // + StringFragment(type: 'raw', value: 'Hello ') // + StringFragment(type: 'expression', value: '%variable%') // + StringFragment(type: 'raw', value: ' World!') Resolves: #97553 Releases: main, 11.5, 10.4 Change-Id: Ie2b02a247ca884fa44ab7b3ba21214c8ee9bc457 Reviewed-on: https://review.typo3.org/c/Packa...
Showing
- typo3/sysext/core/Classes/Utility/String/StringFragment.php 75 additions, 0 deletionstypo3/sysext/core/Classes/Utility/String/StringFragment.php
- typo3/sysext/core/Classes/Utility/String/StringFragmentCollection.php 120 additions, 0 deletions.../core/Classes/Utility/String/StringFragmentCollection.php
- typo3/sysext/core/Classes/Utility/String/StringFragmentPattern.php 55 additions, 0 deletions...ext/core/Classes/Utility/String/StringFragmentPattern.php
- typo3/sysext/core/Classes/Utility/String/StringFragmentSplitter.php 110 additions, 0 deletions...xt/core/Classes/Utility/String/StringFragmentSplitter.php
- typo3/sysext/core/Tests/Unit/Utility/String/StringFragmentCollectionTest.php 117 additions, 0 deletions...ests/Unit/Utility/String/StringFragmentCollectionTest.php
- typo3/sysext/core/Tests/Unit/Utility/String/StringFragmentSplitterTest.php 96 additions, 0 deletions.../Tests/Unit/Utility/String/StringFragmentSplitterTest.php
Please register or sign in to comment