class_string.rst 50 KB

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