We have the following String functions in Apache Pig.
S.N. | Functions & Description |
---|---|
1 | ENDSWITH(string, testAgainst)
To verify whether a given string ends with a particular substring. |
2 | STARTSWITH(string, substring)
Accepts two string parameters and verifies whether the first string starts with the second. |
3 | SUBSTRING(string, startIndex, stopIndex)
Returns a substring from a given string. |
4 | EqualsIgnoreCase(string1, string2)
To compare two stings ignoring the case. |
5 | INDEXOF(string, ‘character’, startIndex)
Returns the first occurrence of a character in a string, searching forward from a start index. |
6 | LAST_INDEX_OF(expression)
Returns the index of the last occurrence of a character in a string, searching backward from a start index. |
7 | LCFIRST(expression)
Converts the first character in a string to lower case. |
8 | UCFIRST(expression)
Returns a string with the first character converted to upper case. |
9 | UPPER(expression)
UPPER(expression) Returns a string converted to upper case. |
10 | LOWER(expression)
Converts all characters in a string to lower case. |
11 | REPLACE(string, ‘oldChar’, ‘newChar’);
To replace existing characters in a string with new characters. |
12 | STRSPLIT(string, regex, limit)
To split a string around matches of a given regular expression. |
13 | STRSPLITTOBAG(string, regex, limit)
Similar to the STRSPLIT() function, it splits the string by given delimiter and returns the result in a bag. |
14 | TRIM(expression)
Returns a copy of a string with leading and trailing whitespaces removed. |
15 | LTRIM(expression)
Returns a copy of a string with leading whitespaces removed. |
16 | RTRIM(expression)
Returns a copy of a string with trailing whitespaces removed. |