To search a string
Various functions are defined in here which allow you to search through a text in different ways.
◆ FindWords()
static size_t FindWords |
( |
const char * | str, |
|
|
const char * | wordLowerCase ) |
|
inlinestatic |
Search for a single word within a text.
- Parameters
-
[in] | str | String to search within |
[in] | wordLowerCase | Word as lowercase to search |
- Returns
- Position in string where word is found, -1 (std::string::npos) if not found
Example:
#include <kodi/tools/StringUtils.h>
size_t ref, var;
ref = 5;
EXPECT_EQ(ref, var);
ref = -1;
EXPECT_EQ(ref, var);
◆ FindEndBracket()
static size_t FindEndBracket |
( |
const std::string & | str, |
|
|
char | opener, |
|
|
char | closer, |
|
|
size_t | startPos = 0 ) |
|
inlinestatic |
Search a string for a given bracket and give its end position.
- Parameters
-
[in] | str | String to search within |
[in] | opener | Begin character to start search |
[in] | closer | End character to end search |
[in] | startPos | [opt] Position to start search in string, 0 as default to start from begin |
- Returns
- End position where found, -1 if failed
Example:
#include <kodi/tools/StringUtils.h>
int ref, var;
ref = 11;
EXPECT_EQ(ref, var);
◆ FindNumber()
static int FindNumber |
( |
const std::string & | strInput, |
|
|
const std::string & | strFind ) |
|
inlinestatic |
Search a text and return the number of parts found as a number.
- Parameters
-
[in] | strInput | Input string to search for |
[in] | strFind | String to search in input |
- Returns
- Amount how much the string is found
Example:
#include <kodi/tools/StringUtils.h>