Count Occurances Of Substring and Seconds to hh::mm:ss with zero trimming!
Dear Community,
I have two new nodes for you today!
Count Occurances of Substring
handy node lets you easily count how many times a single character or a substring appears in another string!
Case sensitivity is optional!
**Seconds to hh:mm:ss**
Expected input is a large number of seconds representing several minutes and/or hours :)
node's primary reason for existing is that I had large intervals in seconds and wanted to trim extra 0's out of the normal output of 00:00:00.00 for the FTimespan conversion and end up with times like these:
```
02:12 00:01 00:99 60:30 01:00:05
```
instead of:
```
00:02:12.00 00:00:01.00 etc :)
```
trimming of 0's is kept **optional** in case you want to compare outputs or do the parsing yourself :)
Here is the code for second node!
Please note my use of **ReplaceInline** wherever possible to avoid copying the entire string in case it is large, **memory efficiency** yay!
```
FString UVictoryBPFunctionLibrary::Victory_SecondsToHoursMinutesSeconds(float Seconds, bool TrimZeroes)
{
FString Str = FTimespan(0, 0, Seconds).ToString();
if(TrimZeroes)
{
FString Left,Right;
Str.Split(TEXT("."),&Left,&Right);
Str = Left;
Str.**ReplaceInline**(TEXT("00:00"), TEXT("00"));
//Str Count!
int32 Count = CountOccurrancesOfSubString(Str,":");
//Remove Empty Hours
if(Count >= 2)
{
Str.**ReplaceInline**(TEXT("00:"), TEXT(""));
}
}
return Str;
}
```
New Download for UE4 4.13 (55mb, Media Fire)
Please note I now use the UE4 Marketplace C++ Plugin Standard when packaging Victory plugin for you
- Win64 Development
- Win64 Shipping <~~~~~~ NEW!
- Win32 Development
- Win32 Shipping
- HTML5 Development
- HTML5 Shipping <~~~~~~ NEW!
Please see my instructions for Packaging UE4 Plugins With Your Game.
**Prior Engine Versions**
**4.12: **http://www.mediafire.com/download/g441k2815r5b045/VictoryPlugin12.zip
**4.11: **http://www.mediafire.com/download/jp91b9atphm2obt/VictoryPlugin11.zip
Donations can be sent to me via: