class_string.rst 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_String:
  4. String
  5. ======
  6. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. Built-in string class.
  10. Member Functions
  11. ----------------
  12. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  13. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`bool<class_bool>` from **)** |
  14. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`int<class_int>` from **)** |
  16. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`float<class_float>` from **)** |
  18. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Vector2<class_vector2>` from **)** |
  20. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Rect2<class_rect2>` from **)** |
  22. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Vector3<class_vector3>` from **)** |
  24. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Matrix32<class_matrix32>` from **)** |
  26. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Plane<class_plane>` from **)** |
  28. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Quat<class_quat>` from **)** |
  30. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`AABB<class_aabb>` from **)** |
  32. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Matrix3<class_matrix3>` from **)** |
  34. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Transform<class_transform>` from **)** |
  36. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Color<class_color>` from **)** |
  38. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`NodePath<class_nodepath>` from **)** |
  40. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`RID<class_rid>` from **)** |
  42. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`InputEvent<class_inputevent>` from **)** |
  44. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Dictionary<class_dictionary>` from **)** |
  46. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Array<class_array>` from **)** |
  48. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`RawArray<class_rawarray>` from **)** |
  50. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`IntArray<class_intarray>` from **)** |
  52. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`RealArray<class_realarray>` from **)** |
  54. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`StringArray<class_stringarray>` from **)** |
  56. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Vector2Array<class_vector2array>` from **)** |
  58. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`Vector3Array<class_vector3array>` from **)** |
  60. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`String<class_string>` | :ref:`String<class_String_String>` **(** :ref:`ColorArray<class_colorarray>` from **)** |
  62. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`String<class_string>` | :ref:`basename<class_String_basename>` **(** **)** |
  64. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`begins_with<class_String_begins_with>` **(** :ref:`String<class_string>` text **)** |
  66. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`StringArray<class_stringarray>` | :ref:`bigrams<class_String_bigrams>` **(** **)** |
  68. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`String<class_string>` | :ref:`c_escape<class_String_c_escape>` **(** **)** |
  70. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`String<class_string>` | :ref:`c_unescape<class_String_c_unescape>` **(** **)** |
  72. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`String<class_string>` | :ref:`capitalize<class_String_capitalize>` **(** **)** |
  74. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`int<class_int>` | :ref:`casecmp_to<class_String_casecmp_to>` **(** :ref:`String<class_string>` to **)** |
  76. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`empty<class_String_empty>` **(** **)** |
  78. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`ends_with<class_String_ends_with>` **(** :ref:`String<class_string>` text **)** |
  80. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`erase<class_String_erase>` **(** :ref:`int<class_int>` pos, :ref:`int<class_int>` chars **)** |
  82. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`String<class_string>` | :ref:`extension<class_String_extension>` **(** **)** |
  84. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`int<class_int>` | :ref:`find<class_String_find>` **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=0 **)** |
  86. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`int<class_int>` | :ref:`find_last<class_String_find_last>` **(** :ref:`String<class_string>` what **)** |
  88. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`int<class_int>` | :ref:`findn<class_String_findn>` **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=0 **)** |
  90. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`String<class_string>` | :ref:`format<class_String_format>` **(** var values, :ref:`String<class_string>` placeholder={_} **)** |
  92. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`String<class_string>` | :ref:`get_base_dir<class_String_get_base_dir>` **(** **)** |
  94. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`String<class_string>` | :ref:`get_file<class_String_get_file>` **(** **)** |
  96. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`int<class_int>` | :ref:`hash<class_String_hash>` **(** **)** |
  98. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`int<class_int>` | :ref:`hex_to_int<class_String_hex_to_int>` **(** **)** |
  100. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`String<class_string>` | :ref:`insert<class_String_insert>` **(** :ref:`int<class_int>` pos, :ref:`String<class_string>` what **)** |
  102. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`bool<class_bool>` | :ref:`is_abs_path<class_String_is_abs_path>` **(** **)** |
  104. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`bool<class_bool>` | :ref:`is_rel_path<class_String_is_rel_path>` **(** **)** |
  106. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`bool<class_bool>` | :ref:`is_subsequence_of<class_String_is_subsequence_of>` **(** :ref:`String<class_string>` text **)** |
  108. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`bool<class_bool>` | :ref:`is_subsequence_ofi<class_String_is_subsequence_ofi>` **(** :ref:`String<class_string>` text **)** |
  110. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`bool<class_bool>` | :ref:`is_valid_float<class_String_is_valid_float>` **(** **)** |
  112. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`bool<class_bool>` | :ref:`is_valid_html_color<class_String_is_valid_html_color>` **(** **)** |
  114. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`bool<class_bool>` | :ref:`is_valid_identifier<class_String_is_valid_identifier>` **(** **)** |
  116. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`bool<class_bool>` | :ref:`is_valid_integer<class_String_is_valid_integer>` **(** **)** |
  118. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`bool<class_bool>` | :ref:`is_valid_ip_address<class_String_is_valid_ip_address>` **(** **)** |
  120. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`String<class_string>` | :ref:`json_escape<class_String_json_escape>` **(** **)** |
  122. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`String<class_string>` | :ref:`left<class_String_left>` **(** :ref:`int<class_int>` pos **)** |
  124. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`int<class_int>` | :ref:`length<class_String_length>` **(** **)** |
  126. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`bool<class_bool>` | :ref:`match<class_String_match>` **(** :ref:`String<class_string>` expr **)** |
  128. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`bool<class_bool>` | :ref:`matchn<class_String_matchn>` **(** :ref:`String<class_string>` expr **)** |
  130. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`RawArray<class_rawarray>` | :ref:`md5_buffer<class_String_md5_buffer>` **(** **)** |
  132. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`String<class_string>` | :ref:`md5_text<class_String_md5_text>` **(** **)** |
  134. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`int<class_int>` | :ref:`nocasecmp_to<class_String_nocasecmp_to>` **(** :ref:`String<class_string>` to **)** |
  136. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`int<class_int>` | :ref:`ord_at<class_String_ord_at>` **(** :ref:`int<class_int>` at **)** |
  138. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`String<class_string>` | :ref:`pad_decimals<class_String_pad_decimals>` **(** :ref:`int<class_int>` digits **)** |
  140. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`String<class_string>` | :ref:`pad_zeros<class_String_pad_zeros>` **(** :ref:`int<class_int>` digits **)** |
  142. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`String<class_string>` | :ref:`percent_decode<class_String_percent_decode>` **(** **)** |
  144. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`String<class_string>` | :ref:`percent_encode<class_String_percent_encode>` **(** **)** |
  146. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`String<class_string>` | :ref:`plus_file<class_String_plus_file>` **(** :ref:`String<class_string>` file **)** |
  148. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`String<class_string>` | :ref:`replace<class_String_replace>` **(** :ref:`String<class_string>` what, :ref:`String<class_string>` forwhat **)** |
  150. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  151. | :ref:`String<class_string>` | :ref:`replacen<class_String_replacen>` **(** :ref:`String<class_string>` what, :ref:`String<class_string>` forwhat **)** |
  152. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  153. | :ref:`int<class_int>` | :ref:`rfind<class_String_rfind>` **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=-1 **)** |
  154. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  155. | :ref:`int<class_int>` | :ref:`rfindn<class_String_rfindn>` **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=-1 **)** |
  156. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  157. | :ref:`String<class_string>` | :ref:`right<class_String_right>` **(** :ref:`int<class_int>` pos **)** |
  158. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  159. | :ref:`RawArray<class_rawarray>` | :ref:`sha256_buffer<class_String_sha256_buffer>` **(** **)** |
  160. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  161. | :ref:`String<class_string>` | :ref:`sha256_text<class_String_sha256_text>` **(** **)** |
  162. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  163. | :ref:`float<class_float>` | :ref:`similarity<class_String_similarity>` **(** :ref:`String<class_string>` text **)** |
  164. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  165. | :ref:`StringArray<class_stringarray>` | :ref:`split<class_String_split>` **(** :ref:`String<class_string>` divisor, :ref:`bool<class_bool>` allow_empty=True **)** |
  166. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  167. | :ref:`RealArray<class_realarray>` | :ref:`split_floats<class_String_split_floats>` **(** :ref:`String<class_string>` divisor, :ref:`bool<class_bool>` allow_empty=True **)** |
  168. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  169. | :ref:`String<class_string>` | :ref:`strip_edges<class_String_strip_edges>` **(** :ref:`bool<class_bool>` left=True, :ref:`bool<class_bool>` right=True **)** |
  170. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  171. | :ref:`String<class_string>` | :ref:`substr<class_String_substr>` **(** :ref:`int<class_int>` from, :ref:`int<class_int>` len **)** |
  172. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  173. | :ref:`RawArray<class_rawarray>` | :ref:`to_ascii<class_String_to_ascii>` **(** **)** |
  174. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  175. | :ref:`float<class_float>` | :ref:`to_float<class_String_to_float>` **(** **)** |
  176. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  177. | :ref:`int<class_int>` | :ref:`to_int<class_String_to_int>` **(** **)** |
  178. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  179. | :ref:`String<class_string>` | :ref:`to_lower<class_String_to_lower>` **(** **)** |
  180. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  181. | :ref:`String<class_string>` | :ref:`to_upper<class_String_to_upper>` **(** **)** |
  182. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  183. | :ref:`RawArray<class_rawarray>` | :ref:`to_utf8<class_String_to_utf8>` **(** **)** |
  184. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  185. | :ref:`String<class_string>` | :ref:`xml_escape<class_String_xml_escape>` **(** **)** |
  186. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  187. | :ref:`String<class_string>` | :ref:`xml_unescape<class_String_xml_unescape>` **(** **)** |
  188. +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  189. Description
  190. -----------
  191. This is the built-in string class (and the one used by GDScript). It supports Unicode and provides all necessary means for string handling. Strings are reference counted and use a copy-on-write approach, so passing them around is cheap in resources.
  192. Member Function Description
  193. ---------------------------
  194. .. _class_String_String:
  195. - :ref:`String<class_string>` **String** **(** :ref:`bool<class_bool>` from **)**
  196. .. _class_String_String:
  197. - :ref:`String<class_string>` **String** **(** :ref:`int<class_int>` from **)**
  198. .. _class_String_String:
  199. - :ref:`String<class_string>` **String** **(** :ref:`float<class_float>` from **)**
  200. .. _class_String_String:
  201. - :ref:`String<class_string>` **String** **(** :ref:`Vector2<class_vector2>` from **)**
  202. .. _class_String_String:
  203. - :ref:`String<class_string>` **String** **(** :ref:`Rect2<class_rect2>` from **)**
  204. .. _class_String_String:
  205. - :ref:`String<class_string>` **String** **(** :ref:`Vector3<class_vector3>` from **)**
  206. .. _class_String_String:
  207. - :ref:`String<class_string>` **String** **(** :ref:`Matrix32<class_matrix32>` from **)**
  208. .. _class_String_String:
  209. - :ref:`String<class_string>` **String** **(** :ref:`Plane<class_plane>` from **)**
  210. .. _class_String_String:
  211. - :ref:`String<class_string>` **String** **(** :ref:`Quat<class_quat>` from **)**
  212. .. _class_String_String:
  213. - :ref:`String<class_string>` **String** **(** :ref:`AABB<class_aabb>` from **)**
  214. .. _class_String_String:
  215. - :ref:`String<class_string>` **String** **(** :ref:`Matrix3<class_matrix3>` from **)**
  216. .. _class_String_String:
  217. - :ref:`String<class_string>` **String** **(** :ref:`Transform<class_transform>` from **)**
  218. .. _class_String_String:
  219. - :ref:`String<class_string>` **String** **(** :ref:`Color<class_color>` from **)**
  220. .. _class_String_String:
  221. - :ref:`String<class_string>` **String** **(** :ref:`NodePath<class_nodepath>` from **)**
  222. .. _class_String_String:
  223. - :ref:`String<class_string>` **String** **(** :ref:`RID<class_rid>` from **)**
  224. .. _class_String_String:
  225. - :ref:`String<class_string>` **String** **(** :ref:`InputEvent<class_inputevent>` from **)**
  226. .. _class_String_String:
  227. - :ref:`String<class_string>` **String** **(** :ref:`Dictionary<class_dictionary>` from **)**
  228. .. _class_String_String:
  229. - :ref:`String<class_string>` **String** **(** :ref:`Array<class_array>` from **)**
  230. .. _class_String_String:
  231. - :ref:`String<class_string>` **String** **(** :ref:`RawArray<class_rawarray>` from **)**
  232. .. _class_String_String:
  233. - :ref:`String<class_string>` **String** **(** :ref:`IntArray<class_intarray>` from **)**
  234. .. _class_String_String:
  235. - :ref:`String<class_string>` **String** **(** :ref:`RealArray<class_realarray>` from **)**
  236. .. _class_String_String:
  237. - :ref:`String<class_string>` **String** **(** :ref:`StringArray<class_stringarray>` from **)**
  238. .. _class_String_String:
  239. - :ref:`String<class_string>` **String** **(** :ref:`Vector2Array<class_vector2array>` from **)**
  240. .. _class_String_String:
  241. - :ref:`String<class_string>` **String** **(** :ref:`Vector3Array<class_vector3array>` from **)**
  242. .. _class_String_String:
  243. - :ref:`String<class_string>` **String** **(** :ref:`ColorArray<class_colorarray>` from **)**
  244. .. _class_String_basename:
  245. - :ref:`String<class_string>` **basename** **(** **)**
  246. If the string is a path to a file, return the path to the file without the extension.
  247. .. _class_String_begins_with:
  248. - :ref:`bool<class_bool>` **begins_with** **(** :ref:`String<class_string>` text **)**
  249. Return true if the strings begins with the given string.
  250. .. _class_String_bigrams:
  251. - :ref:`StringArray<class_stringarray>` **bigrams** **(** **)**
  252. Return the bigrams (pairs of consecutive letters) of this string.
  253. .. _class_String_c_escape:
  254. - :ref:`String<class_string>` **c_escape** **(** **)**
  255. Return a copy of the string with special characters escaped using the C language standard.
  256. .. _class_String_c_unescape:
  257. - :ref:`String<class_string>` **c_unescape** **(** **)**
  258. Return a copy of the string with escaped characters replaced by their meanings according to the C language standard.
  259. .. _class_String_capitalize:
  260. - :ref:`String<class_string>` **capitalize** **(** **)**
  261. Change the case of some letters. Replace underscores with spaces, convert all letters to lowercase then capitalize first and every letter following the space character. For ``capitalize camelCase mixed_with_underscores`` it will return ``Capitalize Camelcase Mixed With Underscores``.
  262. .. _class_String_casecmp_to:
  263. - :ref:`int<class_int>` **casecmp_to** **(** :ref:`String<class_string>` to **)**
  264. Perform a case-sensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
  265. .. _class_String_empty:
  266. - :ref:`bool<class_bool>` **empty** **(** **)**
  267. Return true if the string is empty.
  268. .. _class_String_ends_with:
  269. - :ref:`bool<class_bool>` **ends_with** **(** :ref:`String<class_string>` text **)**
  270. Return true if the strings ends with the given string.
  271. .. _class_String_erase:
  272. - void **erase** **(** :ref:`int<class_int>` pos, :ref:`int<class_int>` chars **)**
  273. Erase ``chars`` characters from the string starting from ``pos``.
  274. .. _class_String_extension:
  275. - :ref:`String<class_string>` **extension** **(** **)**
  276. If the string is a path to a file, return the extension.
  277. .. _class_String_find:
  278. - :ref:`int<class_int>` **find** **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=0 **)**
  279. Find the first occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
  280. .. _class_String_find_last:
  281. - :ref:`int<class_int>` **find_last** **(** :ref:`String<class_string>` what **)**
  282. Find the last occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
  283. .. _class_String_findn:
  284. - :ref:`int<class_int>` **findn** **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=0 **)**
  285. Find the first occurrence of a substring but search as case-insensitive, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed.
  286. .. _class_String_format:
  287. - :ref:`String<class_string>` **format** **(** var values, :ref:`String<class_string>` placeholder={_} **)**
  288. .. _class_String_get_base_dir:
  289. - :ref:`String<class_string>` **get_base_dir** **(** **)**
  290. If the string is a path to a file, return the base directory.
  291. .. _class_String_get_file:
  292. - :ref:`String<class_string>` **get_file** **(** **)**
  293. If the string is a path to a file, return the file and ignore the base directory.
  294. .. _class_String_hash:
  295. - :ref:`int<class_int>` **hash** **(** **)**
  296. Hash the string and return a 32 bits integer.
  297. .. _class_String_hex_to_int:
  298. - :ref:`int<class_int>` **hex_to_int** **(** **)**
  299. Convert a string containing an hexadecimal number into an int.
  300. .. _class_String_insert:
  301. - :ref:`String<class_string>` **insert** **(** :ref:`int<class_int>` pos, :ref:`String<class_string>` what **)**
  302. Insert a substring at a given position.
  303. .. _class_String_is_abs_path:
  304. - :ref:`bool<class_bool>` **is_abs_path** **(** **)**
  305. If the string is a path to a file or directory, return true if the path is absolute.
  306. .. _class_String_is_rel_path:
  307. - :ref:`bool<class_bool>` **is_rel_path** **(** **)**
  308. If the string is a path to a file or directory, return true if the path is relative.
  309. .. _class_String_is_subsequence_of:
  310. - :ref:`bool<class_bool>` **is_subsequence_of** **(** :ref:`String<class_string>` text **)**
  311. Check whether this string is a subsequence of the given string.
  312. .. _class_String_is_subsequence_ofi:
  313. - :ref:`bool<class_bool>` **is_subsequence_ofi** **(** :ref:`String<class_string>` text **)**
  314. Check whether this string is a subsequence of the given string, without considering case.
  315. .. _class_String_is_valid_float:
  316. - :ref:`bool<class_bool>` **is_valid_float** **(** **)**
  317. Check whether the string contains a valid float.
  318. .. _class_String_is_valid_html_color:
  319. - :ref:`bool<class_bool>` **is_valid_html_color** **(** **)**
  320. Check whether the string contains a valid color in HTML notation.
  321. .. _class_String_is_valid_identifier:
  322. - :ref:`bool<class_bool>` **is_valid_identifier** **(** **)**
  323. Check whether the string is a valid identifier. As is common in programming languages, a valid identifier may contain only letters, digits and underscores (\_) and the first character may not be a digit.
  324. .. _class_String_is_valid_integer:
  325. - :ref:`bool<class_bool>` **is_valid_integer** **(** **)**
  326. Check whether the string contains a valid integer.
  327. .. _class_String_is_valid_ip_address:
  328. - :ref:`bool<class_bool>` **is_valid_ip_address** **(** **)**
  329. Check whether the string contains a valid IP address.
  330. .. _class_String_json_escape:
  331. - :ref:`String<class_string>` **json_escape** **(** **)**
  332. Return a copy of the string with special characters escaped using the JSON standard.
  333. .. _class_String_left:
  334. - :ref:`String<class_string>` **left** **(** :ref:`int<class_int>` pos **)**
  335. Return an amount of characters from the left of the string.
  336. .. _class_String_length:
  337. - :ref:`int<class_int>` **length** **(** **)**
  338. Return the length of the string in characters.
  339. .. _class_String_match:
  340. - :ref:`bool<class_bool>` **match** **(** :ref:`String<class_string>` expr **)**
  341. Do a simple expression match, where '\*' matches zero or more arbitrary characters and '?' matches any single character except '.'.
  342. .. _class_String_matchn:
  343. - :ref:`bool<class_bool>` **matchn** **(** :ref:`String<class_string>` expr **)**
  344. Do a simple case insensitive expression match, using ? and \* wildcards (see :ref:`match<class_String_match>`).
  345. .. _class_String_md5_buffer:
  346. - :ref:`RawArray<class_rawarray>` **md5_buffer** **(** **)**
  347. Return the MD5 hash of the string as an array of bytes.
  348. .. _class_String_md5_text:
  349. - :ref:`String<class_string>` **md5_text** **(** **)**
  350. Return the MD5 hash of the string as a string.
  351. .. _class_String_nocasecmp_to:
  352. - :ref:`int<class_int>` **nocasecmp_to** **(** :ref:`String<class_string>` to **)**
  353. Perform a case-insensitive comparison to another string, return -1 if less, 0 if equal and +1 if greater.
  354. .. _class_String_ord_at:
  355. - :ref:`int<class_int>` **ord_at** **(** :ref:`int<class_int>` at **)**
  356. Return the character code at position ``at``.
  357. .. _class_String_pad_decimals:
  358. - :ref:`String<class_string>` **pad_decimals** **(** :ref:`int<class_int>` digits **)**
  359. Format a number to have an exact number of ``digits`` after the decimal point.
  360. .. _class_String_pad_zeros:
  361. - :ref:`String<class_string>` **pad_zeros** **(** :ref:`int<class_int>` digits **)**
  362. Format a number to have an exact number of ``digits`` before the decimal point.
  363. .. _class_String_percent_decode:
  364. - :ref:`String<class_string>` **percent_decode** **(** **)**
  365. Decode a percent-encoded string. See :ref:`percent_encode<class_String_percent_encode>`.
  366. .. _class_String_percent_encode:
  367. - :ref:`String<class_string>` **percent_encode** **(** **)**
  368. Percent-encode a string. This is meant to encode parameters in a URL when sending a HTTP GET request and bodies of form-urlencoded POST request.
  369. .. _class_String_plus_file:
  370. - :ref:`String<class_string>` **plus_file** **(** :ref:`String<class_string>` file **)**
  371. If the string is a path, this concatenates ``file`` at the end of the string as a subpath. E.g. ``"this/is".plus_file("path") == "this/is/path"``.
  372. .. _class_String_replace:
  373. - :ref:`String<class_string>` **replace** **(** :ref:`String<class_string>` what, :ref:`String<class_string>` forwhat **)**
  374. Replace occurrences of a substring for different ones inside the string.
  375. .. _class_String_replacen:
  376. - :ref:`String<class_string>` **replacen** **(** :ref:`String<class_string>` what, :ref:`String<class_string>` forwhat **)**
  377. Replace occurrences of a substring for different ones inside the string, but search case-insensitive.
  378. .. _class_String_rfind:
  379. - :ref:`int<class_int>` **rfind** **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=-1 **)**
  380. Perform a search for a substring, but start from the end of the string instead of the beginning.
  381. .. _class_String_rfindn:
  382. - :ref:`int<class_int>` **rfindn** **(** :ref:`String<class_string>` what, :ref:`int<class_int>` from=-1 **)**
  383. Perform a search for a substring, but start from the end of the string instead of the beginning. Also search case-insensitive.
  384. .. _class_String_right:
  385. - :ref:`String<class_string>` **right** **(** :ref:`int<class_int>` pos **)**
  386. Return the right side of the string from a given position.
  387. .. _class_String_sha256_buffer:
  388. - :ref:`RawArray<class_rawarray>` **sha256_buffer** **(** **)**
  389. .. _class_String_sha256_text:
  390. - :ref:`String<class_string>` **sha256_text** **(** **)**
  391. Return the SHA-256 hash of the string as a string.
  392. .. _class_String_similarity:
  393. - :ref:`float<class_float>` **similarity** **(** :ref:`String<class_string>` text **)**
  394. Return the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar.
  395. .. _class_String_split:
  396. - :ref:`StringArray<class_stringarray>` **split** **(** :ref:`String<class_string>` divisor, :ref:`bool<class_bool>` allow_empty=True **)**
  397. Split the string by a divisor string, return an array of the substrings. Example "One,Two,Three" will return "One","Two","Three" if split by ",".
  398. .. _class_String_split_floats:
  399. - :ref:`RealArray<class_realarray>` **split_floats** **(** :ref:`String<class_string>` divisor, :ref:`bool<class_bool>` allow_empty=True **)**
  400. Split the string in floats by using a divisor string, return an array of the substrings. Example "1,2.5,3" will return 1,2.5,3 if split by ",".
  401. .. _class_String_strip_edges:
  402. - :ref:`String<class_string>` **strip_edges** **(** :ref:`bool<class_bool>` left=True, :ref:`bool<class_bool>` right=True **)**
  403. Return a copy of the string stripped of any non-printable character at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively.
  404. .. _class_String_substr:
  405. - :ref:`String<class_string>` **substr** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` len **)**
  406. Return part of the string from the position ``from``, with length ``len``.
  407. .. _class_String_to_ascii:
  408. - :ref:`RawArray<class_rawarray>` **to_ascii** **(** **)**
  409. Convert the String (which is a character array) to RawArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters.
  410. .. _class_String_to_float:
  411. - :ref:`float<class_float>` **to_float** **(** **)**
  412. Convert a string, containing a decimal number, into a ``float``.
  413. .. _class_String_to_int:
  414. - :ref:`int<class_int>` **to_int** **(** **)**
  415. Convert a string, containing an integer number, into an ``int``.
  416. .. _class_String_to_lower:
  417. - :ref:`String<class_string>` **to_lower** **(** **)**
  418. Return the string converted to lowercase.
  419. .. _class_String_to_upper:
  420. - :ref:`String<class_string>` **to_upper** **(** **)**
  421. Return the string converted to uppercase.
  422. .. _class_String_to_utf8:
  423. - :ref:`RawArray<class_rawarray>` **to_utf8** **(** **)**
  424. Convert the String (which is an array of characters) to RawArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii().
  425. .. _class_String_xml_escape:
  426. - :ref:`String<class_string>` **xml_escape** **(** **)**
  427. Return a copy of the string with special characters escaped using the XML standard.
  428. .. _class_String_xml_unescape:
  429. - :ref:`String<class_string>` **xml_unescape** **(** **)**
  430. Return a copy of the string with escaped characters replaced by their meanings according to the XML standard.