Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2020

regex_replace function

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Built-in functions
    • Labels:
      None

      Description

      I've needed this many times and usually resort to arrays and rewriting the string from the array, which is painful.

      The function proposed: @string_replace(string, pattern, replacement, global true/false)@

      @string@: any CFE string
      @pattern@: a PCRE regex, anchored
      @replacement@: a string to replace the whole @pattern@ every time it's found. Backreferences may be allowed (optional feature)
      @global@: a true/false value to indicate if the replacement will be done on the first match or everywhere.

      I think I can implement this, starting with a @BufferReplaceRegex@ function.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10038 jimis (Dimitrios Apostolou)
                Reporter:
                tzz Ted Zlatanov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel