strops

package
Version: v0.0.0-...-f67e78c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StrOps

type StrOps struct {
	StrIn  string
	StrOut string
}

StrOps - encapsulates a collection of methods used to manipulate strings

func (StrOps) FindRegExIndex

func (sops StrOps) FindRegExIndex(targetStr string, regex string) []int

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

func (sops StrOps) GetSoftwareVersion() string

GetSoftwareVersion - Returns the software version for StrOps.

func (StrOps) ReplaceMultipleStrs

func (sops StrOps) ReplaceMultipleStrs(targetStr string, replaceMap [][][]string) string

ReplaceMultipleStrs - Replaces all instances of string replaceMap[i][0][0] with replacement string replaceMap[i][0][1] in 'targetStr'

func (StrOps) StrCenterInStr

func (sops StrOps) StrCenterInStr(strToCenter string, fieldLen int) (string, error)

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

func (sops StrOps) StrCenterInStrLeft(strToCenter string, fieldLen int) (string, error)

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

func (sops StrOps) StrGetCharCnt(targetStr string) int

StrGetCharCnt - Uses the 'len' method to return the number of characters in a string.

func (StrOps) StrGetRuneCnt

func (sops StrOps) StrGetRuneCnt(targetStr string) int

StrGetRuneCnt - Uses utf8 Rune Count function to return the number of characters in a string.

func (StrOps) StrLeftJustify

func (sops StrOps) StrLeftJustify(strToJustify string, fieldLen int) (string, error)

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

func (sops StrOps) StrPadLeftToCenter(strToCenter string, fieldLen int) (string, error)

StrPadLeftToCenter - Returns a blank string which allows centering of the target string in a fixed length field.

func (StrOps) StrRightJustify

func (sops StrOps) StrRightJustify(strToJustify string, fieldLen int) (string, error)

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

func (sops StrOps) SwapRune(currentStr string, oldRune rune, newRune rune) (string, error)

SwapRune - Swaps all instances of 'oldRune' character with 'newRune' character.

func (StrOps) TrimEndMultiple

func (sops StrOps) TrimEndMultiple(targetStr string, trimChar rune) (rStr string, err error)

TrimMultipleChars - Performs the following operations on strings:

1. Trims Right and Left for all instances of 'trimChar' 2. 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"

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL