‪TYPO3CMS  9.5
TYPO3\CMS\Core\Utility\StringUtility Class Reference

Static Public Member Functions

static bool beginsWith ($haystack, $needle)
 
static bool endsWith ($haystack, $needle)
 
static string getUniqueId ($prefix='')
 
static string escapeCssSelector (string $selector)
 
static string removeByteOrderMark (string $input)
 
static bool searchStringWildcard ($haystack, $needle)
 

Detailed Description

Class with helper functions for string handling

Definition at line 20 of file StringUtility.php.

Member Function Documentation

◆ beginsWith()

static bool TYPO3\CMS\Core\Utility\StringUtility::beginsWith (   $haystack,
  $needle 
)
static

Returns TRUE if $haystack begins with $needle. The input string is not trimmed before and search is done case sensitive.

Parameters
string$haystack‪Full string to check
string$needle‪Reference string which must be found as the "first part" of the full string
Exceptions

Definition at line 31 of file StringUtility.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\beginsWithReturnsFalseForNotMatchingFirstPart(), TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\beginsWithReturnsThrowsExceptionWithInvalidArguments(), TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\beginsWithReturnsTrueForMatchingFirstPart(), and TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager\getAccessibleFormStorageFolders().

◆ endsWith()

◆ escapeCssSelector()

static string TYPO3\CMS\Core\Utility\StringUtility::escapeCssSelector ( string  $selector)
static

Escape a CSS selector to be used for DOM queries

This method takes care to escape any CSS selector meta character. The result may be used to query the DOM like $('#' + escapedSelector)

Parameters
string$selector
Returns
‪string

Definition at line 106 of file StringUtility.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\escapeCssSelector(), and TYPO3\CMS\Backend\Form\Container\InlineControlContainer\renderPossibleRecordsSelectorTypeGroupDB().

◆ getUniqueId()

static string TYPO3\CMS\Core\Utility\StringUtility::getUniqueId (   $prefix = '')
static

This function generates a unique id by using the more entropy parameter. Furthermore the dots are removed so the id can be used inside HTML attributes e.g. id.

Parameters
string$prefix
Returns
‪string

Definition at line 91 of file StringUtility.php.

Referenced by TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseUniqueUidNewRow\addData(), TYPO3\CMS\Impexp\Import\addSingle(), TYPO3\CMS\Install\FolderStructure\DirectoryNode\canFileBeCreated(), TYPO3\CMS\Install\Service\CoreUpdateService\checkPreConditions(), TYPO3\CMS\Backend\Controller\FormFlexAjaxController\containerAdd(), TYPO3\CMS\Install\Controller\EnvironmentController\convertImageFormatsToJpg(), TYPO3\CMS\Core\DataHandling\DataHandler\copyRecord(), TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\AbstractActionTestCase\createLocalizedContent(), TYPO3\CMS\Rsaauth\Backend\CommandLineBackend\createNewKeyPair(), TYPO3\CMS\Rsaauth\Backend\CommandLineBackend\decrypt(), TYPO3\CMS\Core\Database\QueryGenerator\getDateTimePickerField(), TYPO3\CMS\Backend\View\PageLayoutView\getTable_tt_content(), TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\getUniqueIdReturnsIdWithoutDot(), TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\getUniqueIdReturnsIdWithPrefix(), TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\HookTest\hooksAreExecutedForNewRelations(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingCombineGifMaskAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingCombineJpgMaskAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGdlibFromFileAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGdlibNiceTextAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGdlibNiceTextShadowAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGdlibRenderTextAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGdlibSimpleAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGifToGifAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingGifToJpgAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingPngToPngAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingTrueTypeAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingWriteGifAction(), TYPO3\CMS\Install\Controller\EnvironmentController\imageProcessingWritePngAction(), TYPO3\CMS\Core\DataHandling\DataHandler\insertNewCopyVersion(), TYPO3\CMS\Core\DataHandling\DataHandler\localize(), TYPO3\CMS\Core\Tests\Functional\DataHandling\IRRE\ForeignField\AbstractActionTestCase\localizeParentContentAndCreateNestedChildrenWithLanguageSynchronization(), TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\pagesTsConfigIsConsideredForAdminUser(), TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\pagesTsConfigIsIgnoredForNonAdminUser(), TYPO3\CMS\Form\Tests\Functional\Hooks\FormFileExtensionUpdateTest\performUpdateSucceedsHavingOutdatedExtensionReferencesWithFinisherOverrides(), TYPO3\CMS\Form\Tests\Functional\Hooks\FormFileExtensionUpdateTest\performUpdateSucceedsHavingOutdatedStorageReferencesWithFinisherOverrides(), TYPO3\CMS\Core\Cache\Backend\RedisBackend\removeIdentifierEntriesAndRelations(), TYPO3\CMS\Backend\Form\FieldControl\AddRecord\render(), TYPO3\CMS\Backend\Form\FieldControl\ListModule\render(), TYPO3\CMS\Backend\Form\FieldControl\ResetSelection\render(), TYPO3\CMS\Backend\Form\FieldControl\TableWizard\render(), TYPO3\CMS\Backend\Form\FieldControl\InsertClipboard\render(), TYPO3\CMS\Rsaauth\Form\Element\RsaInputElement\render(), TYPO3\CMS\Backend\Form\Element\InputColorPickerElement\render(), TYPO3\CMS\Backend\Form\Element\InputDateTimeElement\render(), TYPO3\CMS\Backend\Form\Element\InputTextElement\render(), TYPO3\CMS\Backend\Form\Element\SelectCheckBoxElement\render(), TYPO3\CMS\Backend\Form\Element\InputSlugElement\render(), TYPO3\CMS\Backend\Form\Element\SelectSingleElement\render(), TYPO3\CMS\Backend\Form\Element\TextElement\render(), TYPO3\CMS\Backend\Form\Element\TextTableElement\render(), TYPO3\CMS\Backend\Form\Element\InputLinkElement\render(), TYPO3\CMS\Backend\Form\Element\SelectMultipleSideBySideElement\render(), TYPO3\CMS\Backend\Form\Element\GroupElement\render(), TYPO3\CMS\Backend\Form\Element\ImageManipulationElement\render(), TYPO3\CMS\Backend\Form\Element\SelectMultipleSideBySideElement\renderReadOnly(), TYPO3\CMS\Backend\Form\Element\SelectSingleBoxElement\renderSelectElement(), TYPO3\CMS\Backend\Form\Element\CheckboxToggleElement\renderSingleCheckboxElement(), TYPO3\CMS\Backend\Form\Element\CheckboxLabeledToggleElement\renderSingleCheckboxElement(), TYPO3\CMS\Backend\Form\Element\CheckboxElement\renderSingleCheckboxElement(), TYPO3\CMS\Core\Cache\Backend\FileBackend\set(), TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend\set(), TYPO3\CMS\Core\DataHandling\Localization\DataMapProcessor\synchronizeInlineRelations(), TYPO3\CMS\Form\Tests\Functional\Hooks\FormFileExtensionUpdateTest\updateIsNotRequiredHavingUpdatedStorageReferencesWithFinisherOverrides(), TYPO3\CMS\Form\Tests\Functional\Hooks\FormFileExtensionUpdateTest\updateIsRequiredHavingOutdatedExtensionReferencesWithFinisherOverrides(), and TYPO3\CMS\Form\Tests\Functional\Hooks\FormFileExtensionUpdateTest\updateIsRequiredHavingOutdatedStorageReferencesWithFinisherOverrides().

◆ removeByteOrderMark()

static string TYPO3\CMS\Core\Utility\StringUtility::removeByteOrderMark ( string  $input)
static

Removes the Byte Order Mark (BOM) from the input string. This method supports UTF-8 encoded strings only!

Parameters
string$input
Returns
‪string

Definition at line 117 of file StringUtility.php.

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\checkIncludeLines(), and TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\removeByteOrderMark().

◆ searchStringWildcard()

static bool TYPO3\CMS\Core\Utility\StringUtility::searchStringWildcard (   $haystack,
  $needle 
)
static

Matching two strings against each other, supporting a "*" wildcard (match many) or a "?" wildcard (match one= or (if wrapped in "/") PCRE regular expressions

Parameters
string$haystack‪The string in which to find $needle.
string$needle‪The string to find in $haystack
Returns
‪bool Returns TRUE if $needle matches or is found in (according to wildcards) $haystack. E.g. if $haystack is "Netscape 6.5" and $needle is "Net*" or "Net*ape" then it returns TRUE.

Definition at line 133 of file StringUtility.php.

Referenced by TYPO3\CMS\Core\ExpressionLanguage\FunctionsProvider\DefaultFunctionsProvider\getLikeFunction(), TYPO3\CMS\Core\Tests\Unit\Utility\StringUtilityTest\searchStringWildcard(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\searchStringWildcard().