class_string.rst 54 KB

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