19 character(len=*),
intent(in) :: s
20 character(len=*),
intent(in) :: substr
23 integer :: substr_len, i, jump
24 substr_len = len(substr)
29 do while (i <= len(s) - len(substr))
30 if (s(i:i+len(substr)-1) == substr)
then 31 sub_count = sub_count + 1
42 character(len=*),
intent(in) :: s
43 character(len=*),
intent(in) :: substr
46 integer :: substr_len, i, jump
47 integer :: max_len, tmp_len
49 substr_len = len(substr)
57 do while (i <= len_trim(s) - len(substr) + 1)
58 if (s(i:i+len(substr)-1) == substr)
then 59 sub_count = sub_count + 1
60 if (tmp_len > max_len) max_len = tmp_len
72 if ((tmp_len + len(substr) - 1) > max_len) max_len = tmp_len + len(substr) - 1
77 character(len=*) :: delimiter
79 integer :: substr_len, i, jump
80 integer :: tmp_idx, start_idx, total
81 integer :: split_length, item_length
83 character(len=:),
allocatable :: split_strings(:)
84 character(len=:),
allocatable :: tmp_str
90 allocate(
character(item_length) :: split_strings(split_length))
91 allocate(
character(item_length) :: tmp_str)
93 substr_len = len(delimiter)
101 do while (i <= len_trim(s) - len(delimiter) + 1)
102 if (s(i:i+len(delimiter)-1) == delimiter)
then 103 if (start_idx /= tmp_idx)
then 104 split_strings(total) = s(start_idx:tmp_idx - 1)
106 split_strings(total) =
"" 109 tmp_idx = tmp_idx + len(delimiter)
114 jump = len(delimiter)
117 tmp_idx = tmp_idx + 1
124 split_strings(total) = s(start_idx:tmp_idx - 1)
129 character(len=:),
allocatable :: strings(:)
132 write (*,
"(A, I0)")
"Length of strings array: ",
size(strings(:))
133 print *,
" -> String array dump:" 135 do i = 1,
size(strings(:))
136 if (strings(i) ==
"")
then 137 write (*,
"(A, I0, A, I0, A, I0, A)")
" --> Position ", i,
": (empty) [Trim length = ", len_trim(strings(i)),
", Full length = ", len(strings(i)),
"]" 139 write (*,
"(A, I0, A, A, A, I0, A, I0, A)")
" --> Position ", i,
": '", trim(strings(i)),
"' [Trim length = ", len_trim(strings(i)),
", Full length = ", len(strings(i)),
"]" 145 character(len=*),
intent(in) :: str_arr(:)
146 integer ,
intent(in) :: arr_length
148 integer :: i, max_len
153 write (*,
"(A, I0)")
" ** max_len_string_array: size(str_arr) is ",
size(str_arr)
157 if (len_trim(str_arr(i)) > max_len) max_len = len_trim(str_arr(i))
159 write (*,
"(A, I0, A, I0)")
"max_len_string_array: str_arr(", i,
") is " // trim(str_arr(i)) //
", size is ", len_trim(str_arr(i))
160 write (*,
"(A, I0)")
"max_len_string_array: max_len is ", max_len
166 character(len=*),
intent(in) :: str_arr(:)
167 integer ,
intent(in) :: arr_length
169 integer :: i, max_len
174 write (*,
"(A, I0)")
" ** max_len_notrim_string_array: size(str_arr) is ",
size(str_arr)
178 if (len(str_arr(i)) > max_len) max_len = len(str_arr(i))
180 write (*,
"(A, I0, A, I0)")
"max_len_notrim_string_array: str_arr(", i,
") is " // trim(str_arr(i)) //
", size is ", len_trim(str_arr(i))
181 write (*,
"(A, I0)")
"max_len_notrim_string_array: max_len is ", max_len
187 character(len=*),
intent(in) :: s
188 character(len=*),
intent(in) :: delimiter
189 character(len=:),
intent(inout),
allocatable :: string_part
191 integer :: substr_len, i, jump
192 integer :: tmp_idx, start_idx, total
198 substr_len = len(delimiter)
206 do while (i <= len_trim(s) - len(delimiter) + 1)
207 if (s(i:i+len(delimiter)-1) == delimiter)
then 212 tmp_idx = tmp_idx + 1
220 if (start_idx == tmp_idx)
then 221 allocate(
character(0) :: string_part)
224 allocate(
character(tmp_idx - start_idx + 1) :: string_part)
225 string_part = s(start_idx:tmp_idx - 1)
228 allocate(
character(len(s)) :: string_part)
integer function lentrim(s)
subroutine string_before_delimiter(s, delimiter, string_part)
integer function max_len_string_array(str_arr, arr_length)
integer function string_get_max_split(s, substr)
integer function max_len_notrim_string_array(str_arr, arr_length)
character(len=:) function, dimension(:), allocatable string_split_index(s, delimiter)
subroutine string_array_dump(strings)
integer function string_count_substr(s, substr)