I need to remove all | that are at the end of a line however many lines there are from a string:
[SSSSSS]
|test1|test2|test1|test2|test1|test2|
|test7|test7|test9||test7|test7|test9|
[EEEEE}
result
[SSSSSS]
|test1|test2|test1|test2|test1|test2
|test7|test7|test9||test7|test7|test9
[EEEEE}
Remove Character From End Of Lines
Re: Remove Character From End Of Lines
Code: Select all
str := "
(
[SSSSSS]
|test1|test2|test1|test2|test1|test2|
|test7|test7|test9||test7|test7|test9|
)"
For key, val in StrSplit(str,"`n")
res .= RTrim(val,"|") "`n"
MsgBox % res
Re: Remove Character From End Of Lines
It works with you example buts it's not working when I read the text file String
FileRead, String, %Filename%
FileRead, String, %Filename%
Re: Remove Character From End Of Lines
Does your Textfile have trailing whitespaces?
Or line endings don't match?
Or line endings don't match?
Re: Remove Character From End Of Lines
Try this RegEx approach, it works on example data:
Code: Select all
SampleText := "
(
[SSSSSS]
|test1|test2|test1|test2|test1|test2|
|test7|test7|test9||test7|test7|test9|
[EEEEE}
)"
MsgBox, % RegExReplace(SampleText, "m`a)\|$")
/* Output:
[SSSSSS]
|test1|test2|test1|test2|test1|test2
|test7|test7|test9||test7|test7|test9
[EEEEE}
*/
Re: Remove Character From End Of Lines
That's named GIGO. Not knowing that you've to rename the var from 'String' to 'str' so it'll work, is like blaming the soup while using a forkIt works with you example buts it's not working when I read the text file String
FileRead, String, %Filename%
And yes, you should attach your sample input file to this thread, so your supporters won't have to guess constantly. Thx for listening
BTW, what's the reason that this [EEEEE} is using a trailing curly brace, while [SSSSSS] isn't?
Re: Remove Character From End Of Lines
So I can't have
I have to have ?
Code: Select all
For key, val in StrSplit(String,"`n")
res .= RTrim(val,"|") "`n"
MsgBox % res
Code: Select all
For key, val in StrSplit(str,"`n")
res .= RTrim(val,"|") "`n"
MsgBox % res
Who is online
Users browsing this forum: No registered users and 343 guests