Jump to content

StringReplace Occurance?


zone97
 Share

Recommended Posts

Is there a way to do a string replace using occurrence as a replacement based upon location? Lets say I have this text in a string.

;+----------------------------------------------------------+
;¦                                                          ¦
;¦                                                          ¦
;¦                                                          ¦
;¦                                                          ¦
;+----------------------------------------------------------+
;¦                                                          ¦
;+----------------------------------------------------------+
If StringLeft($text, 1) = ";" Then
                $text = StringReplace($text, '+-', '╔═', 1)
                $text = StringReplace($text, '--', '══')
                $text = StringReplace($text, '-+', '═╗', 1)
                $text = StringReplace($text, '¦', '║')
                $text = StringReplace($text, '+-', '╟─', 1)
                $text = StringReplace($text, '--', '──')
                $text = StringReplace($text, '-+', '─╢', 1)
                $text = StringReplace($text, '+-', '╚═', 1)
                $text = StringReplace($text, '--', '══')
                $text = StringReplace($text, '-+', '═╝', 1)
            EndIf

This obviously doesn't work? I have even tried to splitstring at @CR but no luck? Any idea how i could get this done?

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

I made it work with this... But now I want to have it scrub a larger text looking for these to update.

If StringLeft($text, 1) = ";" Then
                $tArray = StringSplit($text, ';')
                $text = ""
                For $x = 1 To $tArray[0] Step 1
                    If $x = 2 Then
                        $tArray[$x] = StringReplace($tArray[$x], '+-', '╔═')
                        $tArray[$x] = StringReplace($tArray[$x], '--', '══')
                        $tArray[$x] = StringReplace($tArray[$x], '-+', '═╗')
                    EndIf
                    If $x > 2 And $x < $tArray[0] Then
                        $tArray[$x] = StringReplace($tArray[$x], '¦', '║')
                        $tArray[$x] = StringReplace($tArray[$x], '+-', '╟─')
                        $tArray[$x] = StringReplace($tArray[$x], '--', '──')
                        $tArray[$x] = StringReplace($tArray[$x], '-+', '─╢')
                    EndIf
                    If $x = $tArray[0] Then
                        $tArray[$x] = StringReplace($tArray[$x], '+-', '╚═')
                        $tArray[$x] = StringReplace($tArray[$x], '--', '══')
                        $tArray[$x] = StringReplace($tArray[$x], '-+', '═╝')
                    EndIf
                    If $x > 1 Then
                        $text = $text & ';' & $tArray[$x]
                    EndIf
                Next
            EndIf

 

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...