Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Text.replace and Text.replace_all. #5122

Closed
wdanilo opened this issue Feb 5, 2023 · 22 comments · Fixed by #5959
Closed

Update Text.replace and Text.replace_all. #5122

wdanilo opened this issue Feb 5, 2023 · 22 comments · Fixed by #5959
Assignees
Labels
-libs Libraries: New libraries to be implemented l-regex p-low Low priority x-new-feature Type: new feature request

Comments

@wdanilo
Copy link
Member

wdanilo commented Feb 5, 2023

This task is automatically imported from the old Task Issue Board and it was originally created by James Dunkerley.
Original issue is here.


Building on top of the new Regex.compile this ticket is to add replace and replace_all to the Pattern object and then retire all the old Regex modules. Note: this will include implementing replacing special target strings.

The replace function loses the ability to target the last instance.

## Find and replace the first instance of `term` in `self`, returning the new
   Text value.

   Arguments:
   - term: The term or pattern to find within `self`. 
   - replacement: What to replace the term matched with.
     If using regular expressions, then the special replacement patterns can be
     used (see below for details).
   - case_sensitivity: Specifies if the text values should be compared case
     sensitively.
   - use_regex: Enable using regular expressions.

   ! Special Replacement Patterns

     The following patterns are supported:

     - `$$`: Inserts an `$`
     - `$&`: Inserts the matched substring.
     - `$n`: Inserts the `n`th (1-indexed) capturing group.
     - `$name`: Inserts the named capturing group called `name`.

   > Example
     Find the first matching section and replace.

         example_replace =
             "abcdefabcdef".replace "abc" "xyz" == "xyzdefabcdef"

   > Example
     Find the first substring matching the regex and replace.

         example_replace =
             "aabbbbccccaabcaaaa".replace "a[ab]c" "def" use_regex=True == "aabbbbccccadefaaaa"

   > Example
     Find the first substring matching the regex and replace with a special pattern.

         example_replace =
             "aabbbbccccaabcaaaa".replace "a([ab]+)c" "_$1_" use_regex=True == "a_bbbb_cccaabcaaaa"
Text.replace : Text -> Text -> Case_Sensitivity -> Boolean -> Text
Text.replace self term="find" replacement="replace" case_sensitivity=Case_Sensitivity.Sensitive use_regex=False =

## Find and replace all instances of `term` in `self`, returning the new Text
   value.

   Arguments:
   - term: The term or pattern to find within `self`. 
   - replacement: What to replace the term matched with.
     If using regular expressions, then the special replacement patterns can be
     used (see below for details).
   - case_sensitivity: Specifies if the text values should be compared case
     sensitively.
   - use_regex: Enable using regular expressions.

   ! Special Replacement Patterns

     The following patterns are supported:

     - `$$`: Inserts an `$`
     - `$&`: Inserts the matched substring.
     - `$n`: Inserts the `n`th (1-indexed) capturing group.
     - `$name`: Inserts the named capturing group called `name`.

   > Example
     Find the all matching sections and replace.

         example_replace_all =
             "abcdefabcdef".replace_all "abc" "xyz" == "xyzdefxyzdef"

   > Example
     Find the all substrings matching the regex and replace.

         example_replace_all =
             "aabbbbccccaabcaaaa".replace_all "a[ab]+c" "def" use_regex=True == "adefcccadefaaaa"

   > Example
     Find the first substring matching the regex and replace with a special pattern.

         example_replace =
             "aabbbbccccaabcaaaa".replace_all "a([ab]+)c" "_$1_" use_regex=True == "a_bbbb_ccca_b_aaaa"
Text.replace_all : Text -> Text -> Case_Sensitivity -> Boolean -> Text
Text.replace_all self term="find" replacement="replace" case_sensitivity=Case_Sensitivity.Sensitive use_regex=False =
@wdanilo wdanilo added this to the Beta Release milestone Feb 6, 2023
@jdunkerley jdunkerley moved this to 📤 Backlog in Issues Board Feb 6, 2023
@GregoryTravis GregoryTravis moved this from 📤 Backlog to 🔧 Implementation in Issues Board Mar 10, 2023
@enso-bot
Copy link

enso-bot bot commented Mar 10, 2023

Greg Travis reports a new STANDUP for today (2023-03-10):

Progress: find, find_all It should be finished by 2023-03-15.

Next Day: Regex tests

@enso-bot
Copy link

enso-bot bot commented Mar 13, 2023

Greg Travis reports a new STANDUP for today (2023-03-13):

Progress: Regex_2_Specs, replace It should be finished by 2023-03-15.

Next Day: replace

@enso-bot
Copy link

enso-bot bot commented Mar 14, 2023

Greg Travis reports a new STANDUP for today (2023-03-14):

Progress: replace, previous PR comments It should be finished by 2023-03-15.

Next Day: tests

@enso-bot
Copy link

enso-bot bot commented Mar 15, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-15):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: brutal merge problems

@enso-bot
Copy link

enso-bot bot commented Mar 15, 2023

Greg Travis reports a new STANDUP for today (2023-03-15):

Progress: replace, previous PR comments It should be finished by 2023-03-16.

Next Day: tests

@enso-bot
Copy link

enso-bot bot commented Mar 16, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-16):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: more unicode/grapheme trickiness

Possible solutions: confirm theory and decide if want to expand to grapheme

@enso-bot
Copy link

enso-bot bot commented Mar 16, 2023

Greg Travis reports a new STANDUP for today (2023-03-16):

Progress: replace Text.replace with new replace. Update tests. Debugging unicode/grapheme weirdness It should be finished by 2023-03-17.

Next Day: decide about grapheme weirdness

@enso-bot
Copy link

enso-bot bot commented Mar 17, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-17):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: fixed grapheme expansion bug; docs; cleanup

@enso-bot
Copy link

enso-bot bot commented Mar 17, 2023

Greg Travis reports a new STANDUP for today (2023-03-17):

Progress: fixed grapheme expansion bug; docs; cleanup It should be finished by 2023-03-18.

Next Day: more small tasks

@enso-bot
Copy link

enso-bot bot commented Mar 20, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-20):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: Need LRU cache for Replacer

@enso-bot
Copy link

enso-bot bot commented Mar 20, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-20):

Summary: There is 2 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: Need LRU cache for Replacer

@enso-bot
Copy link

enso-bot bot commented Mar 20, 2023

Greg Travis reports a new STANDUP for today (2023-03-20):

Progress: Implemented LRU cache for replacer It should be finished by 2023-03-21.

Next Day: review

@enso-bot
Copy link

enso-bot bot commented Mar 21, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-21):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: More review stuff

@enso-bot
Copy link

enso-bot bot commented Mar 21, 2023

Greg Travis reports a new STANDUP for today (2023-03-21):

Progress: More review stuff It should be finished by 2023-03-22.

Next Day: review

@enso-bot
Copy link

enso-bot bot commented Mar 22, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-22):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: More review stuff

@enso-bot
Copy link

enso-bot bot commented Mar 22, 2023

Greg Travis reports a new STANDUP for today (2023-03-22):

Progress: Making things consistent across all regex methods It should be finished by 2023-03-23.

Next Day: more of the same

@enso-bot
Copy link

enso-bot bot commented Mar 23, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-23):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: More review stuff

@enso-bot
Copy link

enso-bot bot commented Mar 23, 2023

Greg Travis reports a new STANDUP for today (2023-03-23):

Progress: Trying to run Table_Tests It should be finished by 2023-03-24.

Next Day: more of the same

@enso-bot
Copy link

enso-bot bot commented Mar 24, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-24):

Summary: There is 1 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: table tests failing

@enso-bot
Copy link

enso-bot bot commented Mar 24, 2023

Greg Travis reports a new STANDUP for today (2023-03-24):

Progress: table tests working It should be finished by 2023-03-25.

Next Day: final review

@jdunkerley jdunkerley moved this from 🔧 Implementation to 👁️ Code review in Issues Board Mar 25, 2023
@enso-bot
Copy link

enso-bot bot commented Mar 27, 2023

Greg Travis reports a new 🔴 DELAY for today (2023-03-27):

Summary: There is 2 day delay in implementation of the Update Text.replace and Text.replace_all. (#5122) task.
It will cause 0 days delay for the delivery of this weekly plan.

Delay Cause: waiting for approval

@enso-bot
Copy link

enso-bot bot commented Mar 27, 2023

Greg Travis reports a new STANDUP for today (2023-03-27):

Progress: split; removing old regex code; book club It should be finished by 2023-03-27.

Next Day: removing old regex code

@mergify mergify bot closed this as completed in #5959 Mar 28, 2023
@github-project-automation github-project-automation bot moved this from 👁️ Code review to 🟢 Accepted in Issues Board Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-libs Libraries: New libraries to be implemented l-regex p-low Low priority x-new-feature Type: new feature request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants