Sleiman Posted March 15, 2004 Share Posted March 15, 2004 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 More sharing options...
CyberSlug Posted March 15, 2004 Share Posted March 15, 2004 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 More sharing options...
scriptkitty Posted March 15, 2004 Share Posted March 15, 2004 (edited) 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 March 15, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Sleiman Posted March 15, 2004 Author Share Posted March 15, 2004 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 More sharing options...
Sleiman Posted March 15, 2004 Author Share Posted March 15, 2004 OK scriptkitty, you are a genious. Your solution works beatifully. Thank You. Sleiman Link to comment Share on other sites More sharing options...
CyberSlug Posted March 15, 2004 Share Posted March 15, 2004 I must be tired. But I'm glad scriptkitty is sharp I was thinking how you could insert cr+lf after MyName, MyAddress, MyCity.The now-obvious solution is to cr+lf before "Name", "Address", "City". 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 More sharing options...
trids Posted March 15, 2004 Share Posted March 15, 2004 (edited) 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. <<thinks: Mmmm, maybe I should put details in Scripts And Scraps forum >> Edited March 15, 2004 by trids Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now