vb.net - Remove extra space in text file -


i creating text file , copying pre-generated excel data it. working fine. output following:

mgssp:imsi= 40211xxxx   ; mgssp:imsi= 40211xxxx   ; mgssp:imsi= 40211xxxx   ; ... 

i want rid of blank spaces after = , before ;. desire output should like:

mgssp:imsi=40211xxxx; mgssp:imsi=40211xxxx; mgssp:imsi=40211xxxx; ... 

i using following code:

if my.computer.filesystem.fileexists("c:\temp\mgssp_script.txt")         dim proc process = process.start("notepad.exe", "c:\temp\mgssp_script.txt")         system.threading.thread.sleep(250)         sendkeys.send("^v")     else         dim file system.io.filestream         file = system.io.file.create("c:\temp\mgssp_script.txt")         file.close()         dim proc process = process.start("notepad.exe", "c:\temp\mgssp_script.txt")         system.threading.thread.sleep(250)         sendkeys.send("^v")         file.close()     end if 

you can clipboard data program using clipboard class in system.windows.forms namespace.

if not winforms application, have add reference system.windows.forms , include imports statement in code: imports system.windows.forms.
also, code uses regex class in system.text.regularexpressions have import well.

this code clipboard data program, replace spaces, , set changed string clipboard.

dim clipboardldata string if clipboard.containstext()     clipboardldata = clipboard.gettext()     dim re regex =  new regex("=\s+") ' = , spaces after     clipboardldata = re.replace(clipboardldata, "=")     re = new regex("\s+;") ' spaces before ;     clipboardldata = re.replace(clipboardldata, ";")      clipboard.settext(clipboardldata) end if 

after can keep using code have open notepad application.


Comments