RealDocs

FString::StartsWith

function Core Since 4.0
#include "Containers/UnrealString.h"
Access: public

Description

Returns true if this string begins with the specified prefix. The comparison is case-insensitive by default. An empty prefix always returns true.

Signature

bool StartsWith(const FString& InPrefix, ESearchCase::Type SearchCase = ESearchCase::IgnoreCase) const

Parameters

Name Type Description Default
InPrefix const FString& The prefix to search for at the start of the string.
SearchCase ESearchCase::Type Whether the comparison is case-sensitive or case-insensitive. ESearchCase::IgnoreCase

Return Type

bool

Caveats & Gotchas

  • Like Contains, the default is case-insensitive. Pass ESearchCase::CaseSensitive for asset paths or identifiers where case matters.
  • An empty prefix string always returns true.
  • When checking multiple prefixes in sequence, consider building a lookup table or using a regex alternative — repeated StartsWith calls are each O(n) and can add up in hot loops.

Example

Check asset path prefix C++
FString Path = TEXT("/Game/Characters/Hero_BP");
if (Path.StartsWith(TEXT("/Game/Characters")))
{
    // filter to character assets only
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.