
functions
files
intro
|
|
yast2 |
modules/String.ycp |
| String manipulation routines |
|
|
|
Global Functions
- CAlnum ()
- CAlpha ()
- CDigit ()
- CGraph ()
- CLower ()
- CPrint ()
- CPunct ()
- CSpace ()
- CUpper ()
- CXdigit ()
- CutBlanks (string input)
- CutRegexMatch (string input, string regex, boolean glob)
- CutZeros (string input)
- EscapeTags (string text)
- FirstChunk (string s, string separators)
- FormatSize (integer bytes)
- FormatSizeWithPrecision (integer bytes, integer precision, boolean omit_zeroes)
- OptFormat (string f, string s)
- OptParens (string s)
- Pad (string text, integer length)
- PadZeros (string text, integer length)
- ParseOptions (string options, map parameters)
- Quote (string var)
- TextTable (list<string> header, list <list <string> > items, map <string, any> options)
- UnQuote (string var)
- UnderlinedHeader (string header_line, integer left_padding)
- ValidCharsFilename ()
|
|
|
|
global Quote (string var) -> string
|
|
Quote a string with 's
- Parameters:
- Return value:
- Example:
-
|
global UnQuote (string var) -> string
|
|
Unquote a string with 's (quoted with quote)
- Parameters:
- Return value:
- See:
-
|
global OptFormat (string f, string s) -> string
|
|
Optional formatted text
- Parameters:
- Return value:
|
|
sformat (f, s) if s is neither empty or nil, else "" |
|
global OptParens (string s) -> string
|
|
Optional parenthesized text
- Parameters:
- Return value:
|
|
" (Foo)" if Foo is neither empty or nil, else "" |
|
global FormatSizeWithPrecision (integer bytes, integer precision, boolean omit_zeroes) -> string
|
|
Return a pretty description of a byte count
Return a pretty description of a byte count with required precision
and using KB, MB or GB as unit as appropriate.
- Parameters:
|
bytes |
size (e.g. free diskspace, memory size) in Bytes |
|
precision |
number of fraction digits in output |
|
omit_zeroes |
if true then do not add zeroes
(usefull for memory size - 128 MB RAM looks better than 128.00 MB RAM) |
- Return value:
- Example:
-
FormatSizeWithPrecision(4096, 2, true) -> "4 KB"
FormatSizeWithPrecision(4096, 2, false) -> "4.00 KB" |
|
global FormatSize (integer bytes) -> string
|
|
Return a pretty description of a byte count
Return a pretty description of a byte count, with two fraction digits
and using KB, MB or GB as unit as appropriate.
- Parameters:
|
bytes |
size (e.g. free diskspace) in Bytes |
- Return value:
- Example:
-
FormatSize(23456767890) -> "223.70 MB" |
|
global CutBlanks (string input) -> string
|
|
Remove blanks at begin and end of input string.
- Parameters:
|
input |
string to be stripped |
- Return value:
- Example:
-
CutBlanks(" any input ") -> "any input" |
|
global CutZeros (string input) -> string
|
|
Remove any leading zeros
Remove any leading zeros that make tointeger inadvertently
assume an octal number (e.g. "09" -> "9", "0001" -> "1",
but "0" -> "0")
- Parameters:
|
input |
number that might contain leadig zero |
- Return value:
|
|
that has leading zeros removed |
|
global Pad (string text, integer length) -> string
|
|
Add spaces after the text to make it long enough
Add spaces after the text to make it long enough. If the text is longer
than requested, no changes are made.
- Parameters:
|
text |
text to be padded |
|
length |
requested length |
- Return value:
|
global PadZeros (string text, integer length) -> string
|
|
Add zeros before the text to make it long enough.
Add zeros before the text to make it long enough. If the text is longer
than requested, no changes are made.
- Parameters:
|
text |
text to be padded |
|
length |
requested length |
- Return value:
|
global ParseOptions (string options, map parameters) -> list<string>
|
|
Parse string of values
- Parameters:
|
options |
Input string |
|
parameters |
Parmeter used at parsing - map with keys:
"separator": - value separator (default: " \t"),
"unique": - result will not contain any duplicates, first occurance of the string is stored into output (default: false),
"interpret_backslash": - convert backslash sequence into one character (e.g. "\\n" => "\n") (default: true)
"remove_whitespace": - remove white spaces around values (default: true), |
- Return value:
|
global CutRegexMatch (string input, string regex, boolean glob) -> string
|
|
Remove first or every match of given regular expression from a string
(e.g. CutRegexMatch( "abcdef12ef34gh000", "[0-9]+", true ) -> "abcdefefgh",
CutRegexMatch( "abcdef12ef34gh000", "[0-9]+", false ) -> "abcdefef34gh000")
- Parameters:
|
input |
string that might occur regex |
|
regex |
regular expression to search for, must not contain brackets |
|
glob |
flag if only first or every occuring match should be removed |
- Return value:
|
global EscapeTags (string text) -> string
|
|
Function for escaping (replacing) (HTML|XML...) tags with their
(HTML|XML...) meaning.
Usable to present text "as is" in RichText.
- Parameters:
- Return value:
|
global FirstChunk (string s, string separators) -> string
|
|
Shorthand for select (splitstring (s, separators), 0, "")
Useful now that the above produces a deprecation warning.
- Parameters:
|
s |
string to be split |
|
separators |
characters which delimit components |
- Return value:
|
global CUpper () -> string
|
|
- Return value:
|
|
the 26 uppercase ASCII letters |
|
global CLower () -> string
|
|
- Return value:
|
|
the 26 lowercase ASCII letters |
|
global CAlpha () -> string
|
|
- Return value:
|
|
the 52 upper and lowercase ASCII letters |
|
global CDigit () -> string
|
|
- Return value:
|
global CXdigit () -> string
|
|
- Return value:
|
|
hexadecimal digits: 0123456789ABCDEFabcdef |
|
global CAlnum () -> string
|
|
- Return value:
|
|
the 52 upper and lowercase ASCII letters and digits |
|
global CPunct () -> string
|
|
- Return value:
|
|
the ASCII printable non-blank non-alphanumeric characters |
|
global CGraph () -> string
|
|
- Return value:
|
|
printable ASCII charcters except whitespace |
|
global CSpace () -> string
|
|
- Return value:
|
global CPrint () -> string
|
|
- Return value:
|
|
printable ASCII characters including whitespace |
|
global ValidCharsFilename () -> string
|
|
Characters valid in a filename (not pathname).
Naturally "/" is disallowed. Otherwise, the graphical ASCII
characters are allowed.
- Return value:
|
global TextTable (list<string> header, list <list <string> > items, map <string, any> options) -> string
|
|
Function creates text table without using HTML tags.
(Useful for commandline)
Undefined option uses the default one.
- Parameters:
- Return value:
|
|
table
Header: [ "Id", "Configuration", "Device" ]
Items: [ [ "1", "aaa", "Samsung Calex" ], [ "2", "bbb", "Trivial Trinitron" ] ]
Possible Options: horizontal_padding (for columns), table_left_padding (for table) |
|
global UnderlinedHeader (string header_line, integer left_padding) -> string
|
|
Function returns underlined text header without using HTML tags.
(Useful for commandline)
- Parameters:
- Return value:
|