Jump to content

Padding A Cr/lf Before A String


Recommended Posts

I have a file txt that has lost all CR/LF characters and now difficult to read. The formatting is gone.

How can I search for specific string and when found, replace it with CR/LF+string.

Example:

Original Format

Name MyName

Address MyAddress

City My City

Current format(bad)

Name MyName Address MyAddress City MyCity

There is more data than the above sample.

Thanks for the help.

Sleiman

Link to comment
Share on other sites

My advice is to get a text editor that supports regular expressions. See the "Text Editor Wars" in the chat forum. I know that Scite, Crimson, and TextPad support regular expression search and replace.

If you've not used regular expressions before, then, post back or search google.

(I'm not seeing an easy way to directly write an AutoIt script to achieve what you want.)

Hope that helps a bit

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

I would suggest anything with regular expressions, but you can do it in autoit if you like.

If it is in the format you say then:

; clipboard version fix
$out=clipget()
$out=StringReplace($out," Name",@crlf & "Name")
$out=StringReplace($out," Address",@crlf & "Address")
$out=StringReplace($out," City",@crlf & "City")
clipput($out)

copy to clipboard, run this, and paste it back in.

Regular expressions are a great thing though.

edit Make sure you back up your data first of course.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

You guys are fast.

Thanks for the tips.

I am familiar with EditPad Pro and have downloaded PowerGrep from JGSoft.

However, I am a bit lost on how to use Regular Expression in these tools. I will try the AutoIt solutions for now.

Thanks Again,

Sleiman

Link to comment
Share on other sites

My advice is to get a text editor that supports regular expressions. See the "Text Editor Wars" in the chat forum. I know that Scite, Crimson, and TextPad support regular expression search and replace.

There's also a commandline grep utility for Windows, which talks in regular expressions and does extreme magyk under the control of Au3. :whistle:

<<thinks: Mmmm, maybe I should put details in Scripts And Scraps forum >>

Edited by trids
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...