Search characters in a string. Arguments: STRING, the target string; CHAR, the character to look for; BEGIN, optional, the index of the character in the target string from which the search begins (defaults to zero).
If the character is found: print an integer representing the index of the last occurrence of CHAR in STRING, then return with status zero. If the character is not found: print nothing and return with status one.
The function variant _var
stores the result in the variable _RV, rather than print it;
Result variables.
mbfl_string_first abcdefghilm d -| 3 mbfl_string_first abcdefghilm a -| 0 mbfl_string_first abcdefghilm m -| 10 mbfl_string_first abcdefghilm X -| <empty string> mbfl_string_first abcdeabcde a 3 -| 5 mbfl_string_first abcdeabcde e 5 -| 9 mbfl_string_first abcdeabcde e 4 -| 4 local _RV mbfl_string_first_var _RV abcdefghilm d "$_RV" ⇒ 3
Search characters in a string starting from the end. Arguments: STRING, the target string; CHAR, the character to look for; BEGIN, optional, the index of the character in the target string from which the search begins (defaults to zero).
If the character is found: print an integer representing the index of the last occurrence of CHAR in STRING, then return with status zero. If the character is not found: print nothing and return with status one.
The function variant _var
stores the result in the variable _RV, rather than print it;
Result variables.
mbfl_string_last abcdefghilm d -| 3 mbfl_string_last abcdefghilm a -| 0 mbfl_string_last abcdefghilm m -| 10 mbfl_string_last abcdefghilm X -| <empty string> mbfl_string_last abcdefghilm a 3 -| 0 mbfl_string_last abcdeabcde a 7 -| 5 mbfl_string_last abcdeabcde e 7 -| 4 mbfl_string_last abcdeabcde e 4 -| 4 local _RV mbfl_string_last_var _RV abcdefghilm d "$_RV" ⇒ 3
Return true if STRING begins with PREFIX; otherwise return false.
mbfl_string_has_prefix 'ciao' 'ciao mamma' ⇒ 0 mbfl_string_has_prefix '' 'ciao mamma' ⇒ 0 mbfl_string_has_prefix 'hello' 'ciao mamma' ⇒ 1 mbfl_string_has_prefix 'hello' '' ⇒ 1
Return true if STRING ends with SUFFIX; otherwise return false.
mbfl_string_has_suffix 'mamma' 'ciao mamma' ⇒ 0 mbfl_string_has_suffix '' 'ciao mamma' ⇒ 0 mbfl_string_has_suffix 'mom' 'ciao mamma' ⇒ 1 mbfl_string_has_suffix 'mom' '' ⇒ 1
Return true if STRING starts with PREFIX and ends with SUFFIX; otherwise return false.
mbfl_string_has_prefix_and_suffix 'ciao' 'ciao mamma' 'o mamma' ⇒ 0 mbfl_string_has_prefix_and_suffix '' 'ciao mamma' 'mamma' ⇒ 0 mbfl_string_has_prefix_and_suffix 'ciao' 'ciao mamma' '' ⇒ 0 mbfl_string_has_prefix_and_suffix '' '' '' ⇒ 0 mbfl_string_has_prefix_and_suffix '' 'ciao mamma' '' ⇒ 0 mbfl_string_has_prefix_and_suffix 'mom' 'ciao mamma' 'mamma' ⇒ 1 mbfl_string_has_prefix_and_suffix 'hello' '' 'mom' ⇒ 1 mbfl_string_has_prefix_and_suffix '' 'ciao mamma' 'mom' ⇒ 1 mbfl_string_has_prefix_and_suffix 'hello' 'ciao mamma' '' ⇒ 1
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.