@@ -192,3 +192,64 @@ program demo
192
192
print'(a)', ends_with("pattern", "pat") ! F
193
193
end program demo
194
194
```
195
+
196
+
197
+ <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
198
+ ### ` slice `
199
+
200
+ #### Description
201
+
202
+ Extracts the characters from the defined region of the input string.
203
+ Argument ` first ` and ` last ` defines the region for the function ` slice ` to operate.
204
+ Extraction starts from the index ` first ` and takes stride of length ` stride ` .
205
+ Argument ` stride ` cannot take the value 0.
206
+
207
+ #### Syntax
208
+
209
+ ` string = [[stdlib_strings(module):slice(interface)]] (string, first, last, stride) `
210
+
211
+ #### Status
212
+
213
+ Experimental
214
+
215
+ #### Class
216
+
217
+ Pure function.
218
+
219
+ #### Argument
220
+
221
+ - ` string ` : Character scalar or [[ stdlib_string_type(module): string_type (type)]]
222
+ This argument is intent(in).
223
+ - ` first ` : integer
224
+ This argument is intent(in) and optional.
225
+ - ` last ` : integer
226
+ This argument is intent(in) and optional.
227
+ - ` stride ` : integer
228
+ This argument is intent(in) and optional.
229
+
230
+ #### Result value
231
+
232
+ The result is of the same type as ` string ` .
233
+
234
+ #### Example
235
+
236
+ ``` fortran
237
+ program demo_slice
238
+ use stdlib_string_type
239
+ use stdlib_strings, only : slice
240
+ implicit none
241
+ type(string_type) :: string
242
+ character(len=10) :: char
243
+
244
+ string = "abcdefghij"
245
+ ! string <-- "abcdefghij"
246
+
247
+ char = "abcdefghij"
248
+ ! char <-- "abcdefghij"
249
+
250
+ print'(a)', slice("abcdefghij", 2, 6, 2) ! "bdf"
251
+ print'(a)', slice(string, 2, 6, 2) ! "bdf"
252
+ print'(a)', slice(char, 2, 6, 2) ! "bdf"
253
+
254
+ end program demo_slice
255
+ ```
0 commit comments