<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>You need something like this.</p>
    <p>Obviously, make backups of your stuff BEFORE trying this code! 
      Use at your own risk!</p>
    <p><br>
    </p>
    <p>| methodReferences replacementString stringToReplace |<br>
      Transcript clear.<br>
      stringToReplace := '123456789012312312 sin'.<br>
      replacementString := '2112 abs'.<br>
      <br>
      methodReferences := Smalltalk allMethodsSourceStringMatching:
      ('*', stringToReplace, '*').<br>
      methodReferences do: [:each |             | class newSourceCode |<br>
                                      <br>
                                      class := each classIsMeta<br>
                                              ifTrue: [(Smalltalk at:
      each classSymbol) class]<br>
                                              ifFalse: [Smalltalk at:
      each classSymbol ].<br>
                                      sourceCode := class sourceCodeAt:
      each methodSymbol.<br>
                                      newSourceCode := sourceCode
      copyReplaceAll: stringToReplace with: replacementString.<br>
                                      <br>
                                      [class compile: newSourceCode]<br>
                                          on: SyntaxErrorNotification<br>
                                          do: [: ex | Transcript cr;
      show: class name, '>>', each methodSymbol]<br>
                                      <br>
                                       ]</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2024-12-14 19:46, Mark Volkmann via
      Cuis-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFfRWnUENaL-D1k=zkAhuRb0-XX_-=-6Zt1Q+-GWYLJLUdz29g@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Is there a provided way to find all occurrences of a given
          string in a method implementation and replace them with a
          given string? I've searched for that and couldn't find it. I
          don't imagine I would use it often, but one use case is
          replacing all occurrences of four spaces with a tab character
          when I paste in code from outside of the image.</div>
        <div><br>
        </div>
        <span class="gmail_signature_prefix">-- </span><br>
        <div dir="ltr" class="gmail_signature"
          data-smartmail="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div dir="ltr">
                      <div><font face="arial, helvetica, sans-serif">R.
                          Mark Volkmann</font></div>
                      <div><span style="font-size:12.8000001907349px"><font
                            face="arial, helvetica, sans-serif">Object
                            Computing, Inc.</font></span></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
    </blockquote>
  </body>
</html>