Jump to content

How do I replace a string with a new line


xOAT
 Share

Recommended Posts

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]

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...