Jump to content
Sign in to follow this  
xOAT

How do I replace a string with a new line

Recommended Posts

xOAT

So for example I have a text file that reads:

This-is-on-line-one+two+three

How do I replace the "+" with a new line so that the file turns into:

This-is-on-line-one
two
three

Share this post


Link to post
Share on other sites
Mecrazycoder

So for example I have a text file that reads:

This-is-on-line-one+two+three

How do I replace the "+" with a new line so that the file turns into:

This-is-on-line-one
two
three

Its work for me.Try it out

$text = StringReplace("This-is-on-line-one+two+three", "+", @CRLF)
MsgBox(0,"",$text)

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Share this post


Link to post
Share on other sites
xOAT

Its work for me.Try it out

$text = StringReplace("This-is-on-line-one+two+three", "+", @CRLF)
MsgBox(0,"",$text)

Aww, I see. I was using @LF for changing the file; which doesn't work. The help file doesn't say to use @CRLF instead. It's confusing using @CR, @LF, and @CRLF on diff. commands for the same outcome. Thanks for the help.

Share this post


Link to post
Share on other sites
bo8ster

They are not the same. One is '\r' (@CR), the other is '\n' (@LF). Windows likes to use '\n' or "\n\r". You will notice @CR also works using StringReplace.

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
Mecrazycoder

Aww, I see. I was using @LF for changing the file; which doesn't work. The help file doesn't say to use @CRLF instead. It's confusing using @CR, @LF, and @CRLF on diff. commands for the same outcome. Thanks for the help.

You are welcome.I think :D @CR alone will also be working. But it is good practice to use @CRLF for windows. Unix-like systems use "\n" and MacOS 9 uses "\r".

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Share this post


Link to post
Share on other sites
jvanegmond

You are welcome.I think :D @CR alone will also be working. But it is good practice to use @CRLF for windows. Unix-like systems use "\n" and MacOS 9 uses "\r".

http://en.wikipedia.org/wiki/Newline#Representations

Share this post


Link to post
Share on other sites
Mecrazycoder

are you sure about this?

I am not 100% sure. Why? is there anything wrong in it?

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Share this post


Link to post
Share on other sites
Mecrazycoder

You just replied to a spam bot.

Oh tanx man.. But how did you find that(Spam bot)

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Share this post


Link to post
Share on other sites
jvanegmond

Oh tanx man.. But how did you find that(Spam bot)

1. Link to advertising in signature

2. Generic and useless reply

3. Just one post. He registered to ask you if you were sure? I think that is a little too much trouble..

4. Smiley face as post icon, no one uses post icons on these forums... l o l.

Share this post


Link to post
Share on other sites
Mecrazycoder

1. Link to advertising in signature

2. Generic and useless reply

3. Just one post. He registered to ask you if you were sure? I think that is a little too much trouble..

4. Smiley face as post icon, no one uses post icons on these forums... l o l.

Oh great tanx man. You are rocking :D

[size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.