How to delete space at satrting of line...
Moderators: JRL, Dorian (MJT support)
How to delete space at satrting of line...
Hi friend ,
I am facing a problem how can i remove the space at the starting of line.
for example :-
abcdefghijklmn
is there any function for this so i can remove all the space (if present in the text file )
thanks a lot
I am facing a problem how can i remove the space at the starting of line.
for example :-
abcdefghijklmn
is there any function for this so i can remove all the space (if present in the text file )
thanks a lot
hi every one.
Hi JVM,
One way is to use Regular Expressions (regex) and VBScript. I found this example from Marcus here:
Remove multiple spaces from text
http://www.mjtnet.com/usergroup/viewtopic.php?t=2009
All it needed was a slight modification to add ^ at the start of the regex pattern to tell it to only match at the beginning of the string... so the modified example below will match one or more "whitespace characters" (a space is one of those but there are others like Tab, etc.) but only at the start of the line... multiple "whitespace characters" within or at the end of the line will not be matched.
Hmm... that would match leading Tabs too. Since you only mentioned spaces, I further changed the regular expression pattern in the example below from "^\s+" to "^ +" which means, match one or more spaces at the beginning of the line. Note that the " chars are not part of the regex pattern itself, they're just delimiters.
Here's the modified code example, again, with thanks to Marcus for providing the original example:
Note that what you put between the "" in the line below...
The above example works for me, hope it works for you.
Enjoy and take care.
One way is to use Regular Expressions (regex) and VBScript. I found this example from Marcus here:
Remove multiple spaces from text
http://www.mjtnet.com/usergroup/viewtopic.php?t=2009
All it needed was a slight modification to add ^ at the start of the regex pattern to tell it to only match at the beginning of the string... so the modified example below will match one or more "whitespace characters" (a space is one of those but there are others like Tab, etc.) but only at the start of the line... multiple "whitespace characters" within or at the end of the line will not be matched.
Hmm... that would match leading Tabs too. Since you only mentioned spaces, I further changed the regular expression pattern in the example below from "^\s+" to "^ +" which means, match one or more spaces at the beginning of the line. Note that the " chars are not part of the regex pattern itself, they're just delimiters.
Here's the modified code example, again, with thanks to Marcus for providing the original example:
Code: Select all
VBSTART
Function ReplWhiteSpace(strng,replchar)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^ +"
regEx.Global = True
ReplWhiteSpace = regEx.Replace(strng,replchar)
End Function
VBEND
Let>Line= Hello. How are you today?
MDL>Before:%Line%
VBEval>ReplWhiteSpace("%Line%",""),newval
MDL>After:%newval%
- VBEval>ReplWhiteSpace("%Line%",""),newval
The above example works for me, hope it works for you.
Enjoy and take care.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

deletin space at the strting of the line..
Hi friend,
thanks for the reply but friend i want to use only macro script..
is this possible i am waiting for reply
Please help me
thanks for the reply but friend i want to use only macro script..

is this possible i am waiting for reply
Please help me
hi every one.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
To remove ALL spaces just do:
StringReplace>line, ,,line
To remove only leading spaces do:
VBSTART
VBEND
VBEval>LTrim("%line%"),line
StringReplace>line, ,,line
To remove only leading spaces do:
VBSTART
VBEND
VBEval>LTrim("%line%"),line
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
How would i ensure that there is no empty line ?
well friends,
One more question
how would i ensure that the give lines last character is the last character of text file and there is no blank line ........
Example:-
i want to ensure that " > "is the last character and their is no further empty line.
waiting for reply... friend
One more question
how would i ensure that the give lines last character is the last character of text file and there is no blank line ........
Example:-
i want to ensure that " > "is the last character and their is no further empty line.
waiting for reply... friend
hi every one.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Are the ending "blank" lines really blank?
If they are just Return codes, then try replacing all %CRLF%%CRLF% with nothing.
But that will also remove any blank lines in the body of the text.
------------------------
Or, read the file, line by line, and rewrite to another file.
Do not write any second sequential Return code. That should end up with a single return code at the end.
If they are just Return codes, then try replacing all %CRLF%%CRLF% with nothing.
But that will also remove any blank lines in the body of the text.
------------------------
Or, read the file, line by line, and rewrite to another file.
Do not write any second sequential Return code. That should end up with a single return code at the end.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
how to ensure that the ">" is the last charcter
hello fiends ,
well as u said to do. i did exactly same but i have problem that i can not replace all %CRLF% from script .
Actually i am giving the data how it should come
hi this a testing data.
hi this a testing data.
hi this a testing data.
hi this a testing data.
Now what my objective is to ensure that there is no space after
and there is no empty line after this.....
if replace %CRLF% than all data will come in a line but want as it is given
so is this possible friend ..
help me out ..
eagerly waiting for reply...
well as u said to do. i did exactly same but i have problem that i can not replace all %CRLF% from script .
Actually i am giving the data how it should come
hi this a testing data.
hi this a testing data.
hi this a testing data.
hi this a testing data.
Now what my objective is to ensure that there is no space after
and there is no empty line after this.....
if replace %CRLF% than all data will come in a line but want as it is given
so is this possible friend ..
help me out ..
eagerly waiting for reply...
hi every one.
Set line one so that the variable file1 refers to your path and file name.
Code: Select all
Let>file1=C:\JVM.txt
ReadFile>%file1%,file
Separate>%file%,>,line
Sub>line_count,1
Let>counter=1
Concat>line_1,>
Repeat>counter
Add>counter,1
Let>value=line_%counter%
Concat>line_1,%value%>
Message>Reading line %counter% of %line_count%
Until>counter,%line_count%
Let>WLN_NOCRLF=1
WriteLn>%temp_dir%~newfile~.tmp,wres,%line_1%
Let>CF_OVERWRITE=1
CopyFile>%temp_dir%~newfile~.tmp,%file1%
DeleteFile>%temp_dir%~newfile~.tmp
MDL>Reading line %counter% of %line_count%%CRLF%Complete...%CRLF%%CRLF%Press OK to continue.
deleting empty lines
well friends
still unresolved .......
i am having a problem i want to delete all empty lines which appears any where...
Now what i got after running the empty line script
for example :-
..........................................................................................................
this is a test data.
this is a test data.
this is a test data.
this is a test data.
this is a test data.
this is a test data.
this is a test data.Press down arrow
cursor position
..................................
if i put my cursor at the end of last line and than press down it goes to next line. it shows there is an empty line. which i don't want so how can i remove this ?
Used code
Please friend help me
eagerly waiting for reply
JVM
still unresolved .......
i am having a problem i want to delete all empty lines which appears any where...
Now what i got after running the empty line script
for example :-
..........................................................................................................
this is a test data.
this is a test data.
this is a test data.
this is a test data.
this is a test data.
this is a test data.
this is a test data.Press down arrow
cursor position
..................................
if i put my cursor at the end of last line and than press down it goes to next line. it shows there is an empty line. which i don't want so how can i remove this ?
Used code
Code: Select all
GetClipBoard>xyz
Separate>%xyz%,CRLF,lines
Let>new1=
Let>k1=0
Repeat>k1
Let>k1=k1+1
Let>thisline=lines_%k1%
Length>thisline,result
if>result>2
ConCat>%new1%,%thisline%
ConCat>%new1%,%CRLF%
endif
Until>k1=lines_count
Let>remarks=new1
PutClipBoard>%remarks%
Please friend help me
eagerly waiting for reply
JVM
hi every one.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
So all you need to do is truncate the entire data by two characters (CR and LF are two characters at the end and you want to remove them):
If you want to be sure that the last two chars are indeed CR and LF respectively first, do this:
This will only remove the last two chars if they are CRLF. Hopefully you can see how it would be easy to do the above in a recursive loop if you want to make it handle the case where there could be several blank lines in a row.
Code: Select all
//to remove last CRLF, simply truncate by 2 chars
GetClipBoard>data
Length>data,lenD
MidStr>data,1,{%lenD%-2},data
PutClipBoard>data
Code: Select all
//to remove last CRLF, simply truncate by 2 chars
GetClipBoard>data
Length>data,lenD
//what are the last two chars? Are they CRLF?
MidStr>data,{%lenD%-1},2,lastChars
//if last two chars are CRLF pair, remove them
If>lastChars=CRLF
MidStr>data,1,{%lenD%-2},data
PutClipBoard>data
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi Marcus,mtettmar wrote:To remove only leading spaces do:
VBSTART
VBEND
VBEval>LTrim("%line%"),line
This is similar, I'm using Trim instead of LTrim.
I am finding that embedded " characters in the string cause the VBScript Trim function to fail, try this:
Code: Select all
VBSTART
VBEND
Let>line= Can lines with embedded " chars be trimmed using VBScript?
VBEval>Trim("%line%"),line
Is there a way around this problem that would make Trim able to handle " characters... and all other odd characters for that matter?
If not, do you have a suggested Macro Script solution for trimming both leading and trailing spaces?
Any other suggestions from the wizards at large also welcome... looking for something unbreakable...
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
That fixed it, thanks Marcus.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
