UKismetStringLibrary::FindSubstring
#include "Kismet/KismetStringLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Finds the starting index of Substring within SearchIn, optionally searching case-sensitively and/or backward from the end.
Caveats & Gotchas
- • Returns -1 (INDEX_NONE) when the substring isn't found; always check against -1 rather than treating 0 as failure.
- • StartPosition defaults to -1, meaning "start from the appropriate end given bSearchFromEnd", not "always start at position 0" — passing 0 explicitly changes behavior when bSearchFromEnd is true.
Signature
static int32 FindSubstring(const FString& SearchIn, const FString& Substring, bool bUseCase = false, bool bSearchFromEnd = false, int32 StartPosition = -1) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| SearchIn | const FString& | The string to search within. | — |
| Substring | const FString& | The string to look for in SearchIn. | — |
| bUseCase | bool | Whether or not to search case-sensitively. | false |
| bSearchFromEnd | bool | Whether or not to start the search from the end of the string instead of the beginning. | false |
| StartPosition | int32 | The position to start the search from. | -1 |
Return Type
int32 Example
Locate a file extension separator C++
int32 DotIndex = UKismetStringLibrary::FindSubstring(FileName, TEXT("."), false, true); Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?