String class lstrip interface¶
This page explains the String
class lstrip
method interface.
What interface is this?¶
The lstrip
method interface removes whitespaces or a specified character(s) from a string’s left edge.
Basic usage¶
The lstrip
accepts the optional string
argument.
If you skip this argument, this interface removes whitespaces (and line breaks) from a string’s left edge.
import apysc as ap
ap.Stage(
stage_width=0,
stage_height=0,
background_color=ap.Color("#333"),
stage_elem_id="stage",
)
string: ap.String = ap.String(" \n aabbaa ")
string = string.lstrip()
ap.assert_equal(string, "aabbaa ")
ap.save_overall_html(dest_dir_path="string_lstrip_basic_usage_1/")
Also, if you specify any value to the string
argument, this interface removes its character(s) from a string’s left edge.
import apysc as ap
ap.Stage(
stage_width=0,
stage_height=0,
background_color=ap.Color("#333"),
stage_elem_id="stage",
)
string: ap.String = ap.String("aabbaa")
string = string.lstrip(string="a")
ap.assert_equal(string, "bbaa")
ap.save_overall_html(dest_dir_path="string_lstrip_basic_usage_2/")
lstrip API¶
Note: the document build script generates and updates this API document section automatically. Maybe this section is duplicated compared with previous sections.
[Interface signature] lstrip(self, *, string: Union[str, ForwardRef('String'), NoneType] = None, variable_name_suffix: str = '') -> 'String'
[Interface summary]
Remove a specified character or string from the beginning of this value.
[Parameters]
string
: Optional[Union[str, “String”]], optionalA character or string to remove from the beginning of this value. If this argument is
None
(default), this method removes spaces and line breaks.
variable_name_suffix
: str, optionalA JavaScript variable name suffix string. This setting is sometimes useful for JavaScript debugging.
[Returns]
result
: StringA stripped result string.
[Examples]
>>> import apysc as ap
>>> _ = ap.Stage()
>>> string: ap.String = ap.String(" aabbcc ")
>>> string = string.lstrip()
>>> string
String("aabbcc ")
>>> string = ap.String("aabbccaa")
>>> string = string.lstrip(string="a")
>>> string
String("bbccaa")