RealDocs

FString::EndsWith

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

Description

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

Signature

bool EndsWith(const FString& InSuffix, ESearchCase::Type SearchCase = ESearchCase::IgnoreCase) const

Parameters

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

Return Type

bool

Caveats & Gotchas

  • Default is case-insensitive. File extension checks (e.g. ".uasset") should use ESearchCase::CaseSensitive on case-sensitive file systems.
  • An empty suffix always returns true.
  • For asset path checks, prefer testing against the full extension including the dot (e.g. TEXT(".uasset")) rather than just the extension letters, to avoid false matches on filenames like "MyTexture_uasset".

Example

File extension check C++
FString FileName = TEXT("Texture_Albedo.uasset");
if (FileName.EndsWith(TEXT(".uasset"), ESearchCase::CaseSensitive))
{
    // process asset
}

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.