Removing space from string after reading it from file using TCL -


I am trying to read a file line through the line and if using any TCL, the white space characters Wants to remove

I am using trim command to remove spaces, but this is not sorted.

details.config (input file) / P>

  sys_username = dinesh sys_password = dinesh ftp_ip = 0.0.0.0 ftp_username = ftpuser ftp_password = ftppassword   

mystr_example.tcl

  #! / Usr / bin / expect set config_file "details.config" set file_handle [open $ config_file] while [[$ $ file_handle line] is done! = -1} {#set line [string trim $ line] (I thought it might be wrong) #set line [string trim $ line] "(Even if we second argument, then it's empty The location is correct.) # Copy it to any other variable set $ line # Now, trim to save it to 'Extreme' set and save the last [string trim $ test] #set final [trim $ string Test ""] --- & gt; It also puts "- $ Final"; } #Billow Example, I got to the internet which is working fine set "Hello World" "origin: & gt; $ str & lt;" Puts "trimmed head:" [string trimbound $ str] & lt; "" Trimmed tail puts: & gt; [String trimmer $ str] & lt; "puts" trimmed both: & gt; [String trim $ str]   

output

  -> sys_username = dinesh #spaces still The output is in -> sys_password = Dinesh - & gt; Ftp_ip = 0.0.0.0 - & gt; ftp_username = ftpuser - & gt; ftp_password = ftppassword Origin: & gt; Hello World & lt; Sorting Head: & gt; Hello World & lt; Trimmed tail: & gt; Hello world & lt; s both layoffs: & gt; Hello world & lt; #spaces removed from here   

What's wrong here Done?

To trim all the whitespace (only Start and end). Instead of using

  regsub -all {\ s} $ test {} last   

.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -