zone97 Posted January 30, 2017 Share Posted January 30, 2017 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 More sharing options...
mikell Posted January 30, 2017 Share Posted January 30, 2017 49 minutes ago, zone97 said: Is there a way to do a string replace using occurrence as a replacement based upon location? This could be done using StringRegExpReplace, with lookarounds in the pattern to base replacements upon what precedes/follows the string to be replaced zone97 1 Link to comment Share on other sites More sharing options...
zone97 Posted January 30, 2017 Author Share Posted January 30, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now