How to replace parts of a string and a more. Swift 4












-1















I have a string:



"Location: &lt;&lt;LesionLoc&gt;&gt;<br>
Quality: &lt;&lt;TESTTEST&gt;&gt;<br>"


End result should be:



Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;
Quality: &lt;span class="span_dropdowntext" keyword="TESTTEST" style="color:blue;font-weight:bold;"contenteditable="False"&gt; TESTTEST&lt;/span&gt;


As you can see, all I have to do is:




  1. Replace &lt;&lt; with &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;


  2. Replace &gt;&gt; with &lt;/span&gt;


  3. And lastly, (which is what is giving me a hard time), inserting the strings "LesionLoc" and "TESTTEST" into the keyword=/"/" part.



Replacing is easy, just use string.replacingOcurences but then I thought it'd be better if I can loop through all the &lt;&lt; and &gt;&gt;, replace it inside the loop and also insert the strings into the keyword part.



I'm really lost in this. Someone has mentioned using index and substring functions to return the new string, but I'm not sure how to approach this.



Thanks.










share|improve this question



























    -1















    I have a string:



    "Location: &lt;&lt;LesionLoc&gt;&gt;<br>
    Quality: &lt;&lt;TESTTEST&gt;&gt;<br>"


    End result should be:



    Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;
    Quality: &lt;span class="span_dropdowntext" keyword="TESTTEST" style="color:blue;font-weight:bold;"contenteditable="False"&gt; TESTTEST&lt;/span&gt;


    As you can see, all I have to do is:




    1. Replace &lt;&lt; with &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;


    2. Replace &gt;&gt; with &lt;/span&gt;


    3. And lastly, (which is what is giving me a hard time), inserting the strings "LesionLoc" and "TESTTEST" into the keyword=/"/" part.



    Replacing is easy, just use string.replacingOcurences but then I thought it'd be better if I can loop through all the &lt;&lt; and &gt;&gt;, replace it inside the loop and also insert the strings into the keyword part.



    I'm really lost in this. Someone has mentioned using index and substring functions to return the new string, but I'm not sure how to approach this.



    Thanks.










    share|improve this question

























      -1












      -1








      -1








      I have a string:



      "Location: &lt;&lt;LesionLoc&gt;&gt;<br>
      Quality: &lt;&lt;TESTTEST&gt;&gt;<br>"


      End result should be:



      Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;
      Quality: &lt;span class="span_dropdowntext" keyword="TESTTEST" style="color:blue;font-weight:bold;"contenteditable="False"&gt; TESTTEST&lt;/span&gt;


      As you can see, all I have to do is:




      1. Replace &lt;&lt; with &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;


      2. Replace &gt;&gt; with &lt;/span&gt;


      3. And lastly, (which is what is giving me a hard time), inserting the strings "LesionLoc" and "TESTTEST" into the keyword=/"/" part.



      Replacing is easy, just use string.replacingOcurences but then I thought it'd be better if I can loop through all the &lt;&lt; and &gt;&gt;, replace it inside the loop and also insert the strings into the keyword part.



      I'm really lost in this. Someone has mentioned using index and substring functions to return the new string, but I'm not sure how to approach this.



      Thanks.










      share|improve this question














      I have a string:



      "Location: &lt;&lt;LesionLoc&gt;&gt;<br>
      Quality: &lt;&lt;TESTTEST&gt;&gt;<br>"


      End result should be:



      Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;
      Quality: &lt;span class="span_dropdowntext" keyword="TESTTEST" style="color:blue;font-weight:bold;"contenteditable="False"&gt; TESTTEST&lt;/span&gt;


      As you can see, all I have to do is:




      1. Replace &lt;&lt; with &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;


      2. Replace &gt;&gt; with &lt;/span&gt;


      3. And lastly, (which is what is giving me a hard time), inserting the strings "LesionLoc" and "TESTTEST" into the keyword=/"/" part.



      Replacing is easy, just use string.replacingOcurences but then I thought it'd be better if I can loop through all the &lt;&lt; and &gt;&gt;, replace it inside the loop and also insert the strings into the keyword part.



      I'm really lost in this. Someone has mentioned using index and substring functions to return the new string, but I'm not sure how to approach this.



      Thanks.







      swift string indexing substring






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 1:13









      alwonggalwongg

      164




      164
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Firstly, you must find your keyword (in this case is LesionLoc and TESTTEST). You can find it by using the NSRegularExpression with regex format &lt;&lt;[a-z0-9]+&gt;&gt;



          Next, replace your &lt;&lt; with



          &lt;span class="span_dropdowntext" keyword="<KEYWORD>"style="color:blue;font-weight:bold;"contenteditable="False"&gt;


          and &gt;&gt; with &lt;/span&gt;.



          You can using this very simple code



          var string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>nQuality: &lt;&lt;TESTTEST&gt;&gt;<br>"

          do {
          let regex = try NSRegularExpression(pattern: "&lt;&lt;[a-z0-9]+&gt;&gt;", options: NSRegularExpression.Options.caseInsensitive)
          for text in regex.matches(in: string, options: , range: NSRange(location: 0, length: string.count)).reversed() {
          let keyword = (string as NSString).substring(with: text.range).replacingOccurrences(of: "&lt;&lt;", with: "").replacingOccurrences(of: "&gt;&gt;", with: "")
          let newString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;(keyword)&lt;/span&gt;"
          string = (string as NSString).replacingCharacters(in: text.range, with: newString)
          }
          print(string)
          } catch {
          print(error.localizedDescription)
          }





          share|improve this answer



















          • 1





            Works great! Thank you very much!

            – alwongg
            Nov 20 '18 at 14:31



















          0














           private func replaceString(_ str : String)->String{
          guard let keyword = findKeyword(str) else{
          fatalError()
          }
          let replacementString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;"

          var newString = str.replacingOccurrences(of: "&gt;&gt", with: "&lt;/span&gt")
          newString = newString.replacingOccurrences(of: "&lt;&lt;", with: replacementString)
          return newString
          }

          private func findKeyword(_ s : String)->String?{
          var str = Array(s)
          let firstKey = "&lt;&lt;"
          let secondKey = "&gt;&gt"

          var startingIndex : Int = 0
          var movingIndex : Int = 0

          while movingIndex < str.count + 1 - secondKey.count && startingIndex < str.count + 1 - firstKey.count{
          if String(str[startingIndex..<startingIndex + firstKey.count]) != firstKey{
          startingIndex += 1
          }else{
          if movingIndex < startingIndex + firstKey.count{
          movingIndex = startingIndex + firstKey.count
          }else{
          if String(str[movingIndex..<movingIndex + secondKey.count]) != secondKey{
          movingIndex += 1
          }else{
          return String(str[startingIndex+firstKey.count..<movingIndex])
          }
          }
          }
          }

          return nil
          }


          Now, you can use the replaceString function to do the work



          let string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>"
          print(replaceString(string))


          your end result will be



          Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;<br>


          There is a "br" at the end of the result string. I don't know if you wanna to remove that or not.. But if you do, you should know how to .






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384861%2fhow-to-replace-parts-of-a-string-and-a-more-swift-4%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Firstly, you must find your keyword (in this case is LesionLoc and TESTTEST). You can find it by using the NSRegularExpression with regex format &lt;&lt;[a-z0-9]+&gt;&gt;



            Next, replace your &lt;&lt; with



            &lt;span class="span_dropdowntext" keyword="<KEYWORD>"style="color:blue;font-weight:bold;"contenteditable="False"&gt;


            and &gt;&gt; with &lt;/span&gt;.



            You can using this very simple code



            var string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>nQuality: &lt;&lt;TESTTEST&gt;&gt;<br>"

            do {
            let regex = try NSRegularExpression(pattern: "&lt;&lt;[a-z0-9]+&gt;&gt;", options: NSRegularExpression.Options.caseInsensitive)
            for text in regex.matches(in: string, options: , range: NSRange(location: 0, length: string.count)).reversed() {
            let keyword = (string as NSString).substring(with: text.range).replacingOccurrences(of: "&lt;&lt;", with: "").replacingOccurrences(of: "&gt;&gt;", with: "")
            let newString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;(keyword)&lt;/span&gt;"
            string = (string as NSString).replacingCharacters(in: text.range, with: newString)
            }
            print(string)
            } catch {
            print(error.localizedDescription)
            }





            share|improve this answer



















            • 1





              Works great! Thank you very much!

              – alwongg
              Nov 20 '18 at 14:31
















            1














            Firstly, you must find your keyword (in this case is LesionLoc and TESTTEST). You can find it by using the NSRegularExpression with regex format &lt;&lt;[a-z0-9]+&gt;&gt;



            Next, replace your &lt;&lt; with



            &lt;span class="span_dropdowntext" keyword="<KEYWORD>"style="color:blue;font-weight:bold;"contenteditable="False"&gt;


            and &gt;&gt; with &lt;/span&gt;.



            You can using this very simple code



            var string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>nQuality: &lt;&lt;TESTTEST&gt;&gt;<br>"

            do {
            let regex = try NSRegularExpression(pattern: "&lt;&lt;[a-z0-9]+&gt;&gt;", options: NSRegularExpression.Options.caseInsensitive)
            for text in regex.matches(in: string, options: , range: NSRange(location: 0, length: string.count)).reversed() {
            let keyword = (string as NSString).substring(with: text.range).replacingOccurrences(of: "&lt;&lt;", with: "").replacingOccurrences(of: "&gt;&gt;", with: "")
            let newString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;(keyword)&lt;/span&gt;"
            string = (string as NSString).replacingCharacters(in: text.range, with: newString)
            }
            print(string)
            } catch {
            print(error.localizedDescription)
            }





            share|improve this answer



















            • 1





              Works great! Thank you very much!

              – alwongg
              Nov 20 '18 at 14:31














            1












            1








            1







            Firstly, you must find your keyword (in this case is LesionLoc and TESTTEST). You can find it by using the NSRegularExpression with regex format &lt;&lt;[a-z0-9]+&gt;&gt;



            Next, replace your &lt;&lt; with



            &lt;span class="span_dropdowntext" keyword="<KEYWORD>"style="color:blue;font-weight:bold;"contenteditable="False"&gt;


            and &gt;&gt; with &lt;/span&gt;.



            You can using this very simple code



            var string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>nQuality: &lt;&lt;TESTTEST&gt;&gt;<br>"

            do {
            let regex = try NSRegularExpression(pattern: "&lt;&lt;[a-z0-9]+&gt;&gt;", options: NSRegularExpression.Options.caseInsensitive)
            for text in regex.matches(in: string, options: , range: NSRange(location: 0, length: string.count)).reversed() {
            let keyword = (string as NSString).substring(with: text.range).replacingOccurrences(of: "&lt;&lt;", with: "").replacingOccurrences(of: "&gt;&gt;", with: "")
            let newString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;(keyword)&lt;/span&gt;"
            string = (string as NSString).replacingCharacters(in: text.range, with: newString)
            }
            print(string)
            } catch {
            print(error.localizedDescription)
            }





            share|improve this answer













            Firstly, you must find your keyword (in this case is LesionLoc and TESTTEST). You can find it by using the NSRegularExpression with regex format &lt;&lt;[a-z0-9]+&gt;&gt;



            Next, replace your &lt;&lt; with



            &lt;span class="span_dropdowntext" keyword="<KEYWORD>"style="color:blue;font-weight:bold;"contenteditable="False"&gt;


            and &gt;&gt; with &lt;/span&gt;.



            You can using this very simple code



            var string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>nQuality: &lt;&lt;TESTTEST&gt;&gt;<br>"

            do {
            let regex = try NSRegularExpression(pattern: "&lt;&lt;[a-z0-9]+&gt;&gt;", options: NSRegularExpression.Options.caseInsensitive)
            for text in regex.matches(in: string, options: , range: NSRange(location: 0, length: string.count)).reversed() {
            let keyword = (string as NSString).substring(with: text.range).replacingOccurrences(of: "&lt;&lt;", with: "").replacingOccurrences(of: "&gt;&gt;", with: "")
            let newString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;(keyword)&lt;/span&gt;"
            string = (string as NSString).replacingCharacters(in: text.range, with: newString)
            }
            print(string)
            } catch {
            print(error.localizedDescription)
            }






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 20 '18 at 2:15









            Quoc NguyenQuoc Nguyen

            1,66851420




            1,66851420








            • 1





              Works great! Thank you very much!

              – alwongg
              Nov 20 '18 at 14:31














            • 1





              Works great! Thank you very much!

              – alwongg
              Nov 20 '18 at 14:31








            1




            1





            Works great! Thank you very much!

            – alwongg
            Nov 20 '18 at 14:31





            Works great! Thank you very much!

            – alwongg
            Nov 20 '18 at 14:31













            0














             private func replaceString(_ str : String)->String{
            guard let keyword = findKeyword(str) else{
            fatalError()
            }
            let replacementString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;"

            var newString = str.replacingOccurrences(of: "&gt;&gt", with: "&lt;/span&gt")
            newString = newString.replacingOccurrences(of: "&lt;&lt;", with: replacementString)
            return newString
            }

            private func findKeyword(_ s : String)->String?{
            var str = Array(s)
            let firstKey = "&lt;&lt;"
            let secondKey = "&gt;&gt"

            var startingIndex : Int = 0
            var movingIndex : Int = 0

            while movingIndex < str.count + 1 - secondKey.count && startingIndex < str.count + 1 - firstKey.count{
            if String(str[startingIndex..<startingIndex + firstKey.count]) != firstKey{
            startingIndex += 1
            }else{
            if movingIndex < startingIndex + firstKey.count{
            movingIndex = startingIndex + firstKey.count
            }else{
            if String(str[movingIndex..<movingIndex + secondKey.count]) != secondKey{
            movingIndex += 1
            }else{
            return String(str[startingIndex+firstKey.count..<movingIndex])
            }
            }
            }
            }

            return nil
            }


            Now, you can use the replaceString function to do the work



            let string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>"
            print(replaceString(string))


            your end result will be



            Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;<br>


            There is a "br" at the end of the result string. I don't know if you wanna to remove that or not.. But if you do, you should know how to .






            share|improve this answer




























              0














               private func replaceString(_ str : String)->String{
              guard let keyword = findKeyword(str) else{
              fatalError()
              }
              let replacementString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;"

              var newString = str.replacingOccurrences(of: "&gt;&gt", with: "&lt;/span&gt")
              newString = newString.replacingOccurrences(of: "&lt;&lt;", with: replacementString)
              return newString
              }

              private func findKeyword(_ s : String)->String?{
              var str = Array(s)
              let firstKey = "&lt;&lt;"
              let secondKey = "&gt;&gt"

              var startingIndex : Int = 0
              var movingIndex : Int = 0

              while movingIndex < str.count + 1 - secondKey.count && startingIndex < str.count + 1 - firstKey.count{
              if String(str[startingIndex..<startingIndex + firstKey.count]) != firstKey{
              startingIndex += 1
              }else{
              if movingIndex < startingIndex + firstKey.count{
              movingIndex = startingIndex + firstKey.count
              }else{
              if String(str[movingIndex..<movingIndex + secondKey.count]) != secondKey{
              movingIndex += 1
              }else{
              return String(str[startingIndex+firstKey.count..<movingIndex])
              }
              }
              }
              }

              return nil
              }


              Now, you can use the replaceString function to do the work



              let string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>"
              print(replaceString(string))


              your end result will be



              Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;<br>


              There is a "br" at the end of the result string. I don't know if you wanna to remove that or not.. But if you do, you should know how to .






              share|improve this answer


























                0












                0








                0







                 private func replaceString(_ str : String)->String{
                guard let keyword = findKeyword(str) else{
                fatalError()
                }
                let replacementString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;"

                var newString = str.replacingOccurrences(of: "&gt;&gt", with: "&lt;/span&gt")
                newString = newString.replacingOccurrences(of: "&lt;&lt;", with: replacementString)
                return newString
                }

                private func findKeyword(_ s : String)->String?{
                var str = Array(s)
                let firstKey = "&lt;&lt;"
                let secondKey = "&gt;&gt"

                var startingIndex : Int = 0
                var movingIndex : Int = 0

                while movingIndex < str.count + 1 - secondKey.count && startingIndex < str.count + 1 - firstKey.count{
                if String(str[startingIndex..<startingIndex + firstKey.count]) != firstKey{
                startingIndex += 1
                }else{
                if movingIndex < startingIndex + firstKey.count{
                movingIndex = startingIndex + firstKey.count
                }else{
                if String(str[movingIndex..<movingIndex + secondKey.count]) != secondKey{
                movingIndex += 1
                }else{
                return String(str[startingIndex+firstKey.count..<movingIndex])
                }
                }
                }
                }

                return nil
                }


                Now, you can use the replaceString function to do the work



                let string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>"
                print(replaceString(string))


                your end result will be



                Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;<br>


                There is a "br" at the end of the result string. I don't know if you wanna to remove that or not.. But if you do, you should know how to .






                share|improve this answer













                 private func replaceString(_ str : String)->String{
                guard let keyword = findKeyword(str) else{
                fatalError()
                }
                let replacementString = "&lt;span class="span_dropdowntext" keyword="(keyword)" style="color:blue;font-weight:bold;"contenteditable="False"&gt;"

                var newString = str.replacingOccurrences(of: "&gt;&gt", with: "&lt;/span&gt")
                newString = newString.replacingOccurrences(of: "&lt;&lt;", with: replacementString)
                return newString
                }

                private func findKeyword(_ s : String)->String?{
                var str = Array(s)
                let firstKey = "&lt;&lt;"
                let secondKey = "&gt;&gt"

                var startingIndex : Int = 0
                var movingIndex : Int = 0

                while movingIndex < str.count + 1 - secondKey.count && startingIndex < str.count + 1 - firstKey.count{
                if String(str[startingIndex..<startingIndex + firstKey.count]) != firstKey{
                startingIndex += 1
                }else{
                if movingIndex < startingIndex + firstKey.count{
                movingIndex = startingIndex + firstKey.count
                }else{
                if String(str[movingIndex..<movingIndex + secondKey.count]) != secondKey{
                movingIndex += 1
                }else{
                return String(str[startingIndex+firstKey.count..<movingIndex])
                }
                }
                }
                }

                return nil
                }


                Now, you can use the replaceString function to do the work



                let string = "Location: &lt;&lt;LesionLoc&gt;&gt;<br>"
                print(replaceString(string))


                your end result will be



                Location: &lt;span class="span_dropdowntext" keyword="LesionLoc" style="color:blue;font-weight:bold;"contenteditable="False"&gt;LesionLoc&lt;/span&gt;<br>


                There is a "br" at the end of the result string. I don't know if you wanna to remove that or not.. But if you do, you should know how to .







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 2:38









                progammingBeignnerprogammingBeignner

                3391315




                3391315






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384861%2fhow-to-replace-parts-of-a-string-and-a-more-swift-4%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?