Skip to content

Replace substring in character/string_type #366

Open
@ivan-pi

Description

@ivan-pi

I also propose to add a few other functions that can be commonly used.

  • Replace function, this can be implemented in several ways:

    • First implementation: string.replace(pos , len, new_string)
      • pos = starting position of the sub-string to be replaced.
      • len = length of the substring
      • new_string = the string that will replace the substring
    • Second implementation: string.replace(pos, old_string, new_string)
      • old_string = substring to be replaced.
      • pos = position to start the search of old_string
      • new_string = string that will replace old_substring
      • This function will replace only the first occurrence of the old_string.
    • Third implementation: string.replaceall(pos, old_string, new_string)
      • This meaning of variables is similar to the second implementation.
      • The difference is it will find and replace all the occurrences of old_string after pos and not just one.
  • We already have an operator to Concat a string with another but I feel we should also implement a function for the same.

The community can have a discussion over the need for such functions and if needed also suggest some other implementation of Replace function.

Originally posted by @ChetanKarwa in #364 (comment)

Metadata

Metadata

Assignees

Labels

APIDiscussion on a specific API for a proposal (exploratory)easyDifficulty level is easy and good for starting into this projecttopic: stringsString processing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions