Ticket #3978: miscstring.au3

File miscstring.au3, 2.1 KB (added by mateocedillo, 13 months ago)
Line 
1; misc string functions
2; by Mateo C
3#include-once
4
5; #FUNCTION# ====================================================================================================================
6; Name ..........: _String_startsWith
7; Description ...: Checks if the string starts with a specific criteria, similar to the function in Python.
8; Syntax ........: _String_startswith($sString, $sStart)
9; Parameters ....: $sString             - The string to be examined.
10;                  $sStart              - A value (string) to check.
11; Return values .: True if the string starts with that value; otherwise, return false. If $sString is not a string, return @error.
12; Author ........: Mateo Cedillo
13; Modified ......:
14; Remarks .......:
15; Related .......:
16; Link ..........:
17; Example .......: Yes
18; ===============================================================================================================================
19Func _String_startsWith($sString, $sStart)
20        If Not IsString($sString) Then Return SetError(1, 0, "")
21        Return $sStart = StringLeft($sString, StringLen($sStart))
22EndFunc   ;==>_String_startsWith
23; #FUNCTION# ====================================================================================================================
24; Name ..........: _String_EndsWith
25; Description ...: Checks if the string ends with a specific criteria, similar to the function in Python.
26; Syntax ........: _String_Endswith($sString, $sEnd)
27; Parameters ....: $sString             - The string to be examined.
28;                  $sEnd                - A value (string) to check.
29; Return values .: True if the string ends with that value; otherwise, return false. If $sString is not a string, return @error
30; Author ........: Mateo Cedillo
31; Modified ......:
32; Remarks .......:
33; Related .......:
34; Link ..........:
35; Example .......: Yes
36; ===============================================================================================================================
37Func _String_EndsWith($sString, $sEnd)
38        If Not IsString($sString) Then Return SetError(1, 0, "")
39        Return $sEnd = StringRight($sString, StringLen($sEnd))
40EndFunc   ;==>_String_EndsWith