-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString ops.txt
More file actions
26 lines (18 loc) · 936 Bytes
/
String ops.txt
File metadata and controls
26 lines (18 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Basic String Functions
#Important
split() - Splits string into words with delimiter passed as argument
array = string.split("seperator") -- if it's csv comma can be used as seperator
join() - Join words and letters and make string as per delimiter provided in argument
"String which combines array".join(Array) -- "".join(Arr1) -- Will join all element Arr without any string as "" is empty
list() - Convert string to each letter array
.replace("String A","String B")
#find
string.find(substring) - find first substring from string and return
string.startswith(substring) - revert true if substring starts with string
#Conversion
textwrap.wrap(text, width=xx) - Subdivide text to width and return to variable
swapcase() - Convert Capital to small and vice versa
capitalize() - Convert first letter to capital
upper() - Convert string to capital
lower() - Convert string to lower
ljust, rjust and center - alignment adjustment