mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: fix typo in string.js.v (#18213)
This commit is contained in:
parent
d0214a254e
commit
abcbba1e81
@ -595,7 +595,7 @@ pub fn (s string) split_nth(delim string, nth int) []string {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mut start := 0
|
mut start := 0
|
||||||
// Take the left part for each delimiter occurence
|
// Take the left part for each delimiter occurrence
|
||||||
for i <= s.len {
|
for i <= s.len {
|
||||||
is_delim := i + delim.len <= s.len && s[i..i + delim.len] == delim
|
is_delim := i + delim.len <= s.len && s[i..i + delim.len] == delim
|
||||||
if is_delim {
|
if is_delim {
|
||||||
@ -625,7 +625,7 @@ struct RepIndex {
|
|||||||
val_idx int
|
val_idx int
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace_each replaces all occurences of the string pairs given in `vals`.
|
// replace_each replaces all occurrences of the string pairs given in `vals`.
|
||||||
// Example: assert 'ABCD'.replace_each(['B','C/','C','D','D','C']) == 'AC/DC'
|
// Example: assert 'ABCD'.replace_each(['B','C/','C','D','D','C']) == 'AC/DC'
|
||||||
[direct_array_access]
|
[direct_array_access]
|
||||||
pub fn (s string) replace_each(vals []string) string {
|
pub fn (s string) replace_each(vals []string) string {
|
||||||
@ -722,7 +722,7 @@ pub fn (s string) replace_each(vals []string) string {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// last_index returns the position of the last occurence of the input string.
|
// last_index returns the position of the last occurrence of the input string.
|
||||||
fn (s string) last_index_(p string) int {
|
fn (s string) last_index_(p string) int {
|
||||||
if p.len > s.len || p.len == 0 {
|
if p.len > s.len || p.len == 0 {
|
||||||
return -1
|
return -1
|
||||||
@ -741,7 +741,7 @@ fn (s string) last_index_(p string) int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// last_index returns the position of the last occurence of the input string.
|
// last_index returns the position of the last occurrence of the input string.
|
||||||
pub fn (s string) last_index(p string) ?int {
|
pub fn (s string) last_index(p string) ?int {
|
||||||
idx := s.last_index_(p)
|
idx := s.last_index_(p)
|
||||||
if idx == -1 {
|
if idx == -1 {
|
||||||
@ -800,7 +800,7 @@ pub fn (s string) split_into_lines() []string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace_once replaces the first occurence of `rep` with the string passed in `with`.
|
// replace_once replaces the first occurrence of `rep` with the string passed in `with`.
|
||||||
pub fn (s string) replace_once(rep string, with_ string) string {
|
pub fn (s string) replace_once(rep string, with_ string) string {
|
||||||
s2 := ''
|
s2 := ''
|
||||||
#s2.val = s.str.replace(rep.str,with_.str)
|
#s2.val = s.str.replace(rep.str,with_.str)
|
||||||
|
Loading…
Reference in New Issue
Block a user