Skip to content

Commit 0ed4655

Browse files
authored
complete translation of builtin-props.md (#16)
1 parent ffdd56b commit 0ed4655

File tree

1 file changed

+81
-2
lines changed

1 file changed

+81
-2
lines changed

docs/en/references/builtin-props.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,88 @@ let x = "Hey, how are you?"
136136
<: x.split(",")
137137
```
138138

139-
Here is the English translation of the provided document while preserving the original formatting:
139+
### @(_v_: str).replace(_old_: str, _new_: str): str
140+
Returns the string where each occurrence of _old_ is replaced by _new_.
140141

141-
---
142+
```aiscript playground
143+
let x = "Hello World!"
144+
145+
<: x.replace("World", "Ai-Chan")
146+
```
147+
148+
### @(_v_: str).index_of(_search_: str, _fromIndex_?: num): num
149+
Locates the first occurrence of _search_ in the string and returns the position.\
150+
When _fromIndex_ is provided, starts the search from that position.\
151+
If _fromIndex_ is a negative value, the position from the tail (str.len + _fromIndex_) is used.\
152+
Returns -1 if not found.
153+
154+
```aiscript playground
155+
let x = "Hello World!"
156+
157+
<: x.index_of("World")
158+
<: x.index_of("World", -7)
159+
```
160+
161+
### @(_v_: str).pad_start(_width_: num, _pad_?: str): str
162+
Returns the string extended to length _width_, pre-filled with repeating _pad_.\
163+
If _pad_ is omitted, it is filled with spaces(`' '`).\
164+
If _pad_ is too long, the end of _pad_ is truncated.
165+
166+
```aiscript playground
167+
let x = "7"
168+
169+
<: `Today is 2024/12/{x.pad_start(2, "0")}`
170+
```
171+
172+
### @(_v_: str).pad_end(_width_: num, _pad_?: str): str
173+
Returns the string extended to length _width_, post-filled with repeating _pad_.\
174+
If _pad_ is omitted, it is filled with spaces(`' '`).\
175+
If _pad_ is too long, the end of _pad_ is truncated.
176+
177+
```aiscript playground
178+
let x = "5"
179+
180+
<: `I want {x.pad_end(4, "0")} yen`
181+
```
182+
183+
### @(_v_: str).trim(): str
184+
Returns the string trimmed of leading and/or trailing spaces.
185+
186+
```aiscript playground
187+
let x = " Hello World! "
188+
189+
<: x.trim()
190+
```
191+
192+
### @(_v_: str).upper(): str
193+
Returns the string with all lowercase letters uppercased.
194+
195+
```aiscript playground
196+
let x = "Hello World!"
197+
198+
<: x.upper()
199+
```
200+
201+
### @(_v_: str).lower(): str
202+
Returns the string with all uppercase letters lowercased.
203+
204+
```aiscript playground
205+
let x = "Hello World!"
206+
207+
<: x.lower()
208+
```
209+
210+
### @(_v_: str).charcode_at(_i_: num): num | null
211+
Returns the [integer from `0` to `65535` representing the UTF-16 code unit](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) of the _i_-th character in the string.\
212+
Index is based on UTF-16 code units.\
213+
If the string contains surrogate pairs, it may return a higher or lower isolated surrogate, depending on the position.\
214+
Returns null when _i_-th character does not exist.
215+
216+
### @(_v_: str).codepoint_at(_i_: num): num | null
217+
Returns the [code point value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) of the _i_-th character in the string.\
218+
Index is based on UTF-16 code units.\
219+
If the string contains a surrogate pair and the specified position is a lower surrogate, the lower isolated surrogate is returned.\
220+
Returns null when _i_-th character does not exist.
142221

143222
## Arrays
144223

0 commit comments

Comments
 (0)