Documentation ¶
Index ¶
- type StrOps
- func (sops StrOps) FindRegExIndex(targetStr string, regex string) []int
- func (sops StrOps) GetSoftwareVersion() string
- func (sops StrOps) ReplaceMultipleStrs(targetStr string, replaceMap [][][]string) string
- func (sops StrOps) StrCenterInStr(strToCenter string, fieldLen int) (string, error)
- func (sops StrOps) StrCenterInStrLeft(strToCenter string, fieldLen int) (string, error)
- func (sops StrOps) StrGetCharCnt(targetStr string) int
- func (sops StrOps) StrGetRuneCnt(targetStr string) int
- func (sops StrOps) StrLeftJustify(strToJustify string, fieldLen int) (string, error)
- func (sops StrOps) StrPadLeftToCenter(strToCenter string, fieldLen int) (string, error)
- func (sops StrOps) StrRightJustify(strToJustify string, fieldLen int) (string, error)
- func (sops StrOps) SwapRune(currentStr string, oldRune rune, newRune rune) (string, error)
- func (sops StrOps) TrimEndMultiple(targetStr string, trimChar rune) (rStr string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StrOps ¶
StrOps - encapsulates a collection of methods used to manipulate strings
func (StrOps) FindRegExIndex ¶
FindRegExIndex - returns a two-element slice of integers defining the location of the leftmost match in targetStr of the regular expression (regex).
Return Value ============ The return value is an array of integers. If no match is found the return value is 'nil'. If regular expression is successfully matched, the match will be located at targetStr[loc[0]:loc[1]]. Again, a return value of 'nil' signals that no match was found.
func (StrOps) GetSoftwareVersion ¶
GetSoftwareVersion - Returns the software version for StrOps.
func (StrOps) ReplaceMultipleStrs ¶
ReplaceMultipleStrs - Replaces all instances of string replaceMap[i][0][0] with replacement string replaceMap[i][0][1] in 'targetStr'
func (StrOps) StrCenterInStr ¶
StrCenterInStr - returns a string which includes a left pad blank string plus the original string, plus a right pad blank string.
The complete string will effectively center the original string is a field of specified length.
func (StrOps) StrCenterInStrLeft ¶
StrCenterInStrLeft - returns a string which includes a left pad blank string plus the original string. It does NOT include the Right pad blank string.
Nevertheless, the complete string will effectively center the original string is a field of specified length.
func (StrOps) StrGetCharCnt ¶
StrGetCharCnt - Uses the 'len' method to return the number of characters in a string.
func (StrOps) StrGetRuneCnt ¶
StrGetRuneCnt - Uses utf8 Rune Count function to return the number of characters in a string.
func (StrOps) StrLeftJustify ¶
StrLeftJustify - Creates a new string with a total length equal to input parameter 'fieldLen'.
Input parameter 'strToJustify' is placed on the left side of the output string and spaces are padded to the right in order to create a string with total length of 'fieldLen'.
Example:
fieldLen = 15 strToJustify = "Hello World" Returned String = "Hello World " String Index = 012345648901234
func (StrOps) StrPadLeftToCenter ¶
StrPadLeftToCenter - Returns a blank string which allows centering of the target string in a fixed length field.
func (StrOps) StrRightJustify ¶
StrRightJustify - Returns a string where input parameter 'strToJustify' is right justified. The length of the returned string is determined by input parameter 'fieldlen'.
func (StrOps) SwapRune ¶
SwapRune - Swaps all instances of 'oldRune' character with 'newRune' character.
func (StrOps) TrimEndMultiple ¶
TrimMultipleChars - Performs the following operations on strings:
- Trims Right and Left for all instances of 'trimChar'
- Within the interior of a string, multiple instances of 'trimChar' are reduce to a single instance.
Example:
targetStr = " Hello World " trimChar = ' ' (One Space) returned string (rStr) = "Hello World"