Find and replace

Hi , I have a file containg fix tags seperated by '|' symbol. I liked to see all the fix tags in a new line. I thought it would be better way to find and replace all the pipe symbol with carraige return or new line chanrater. I dont know how to do it. Any suggestions.

eg) 8=FIX.4.4|9=197|35=9|34=59518|52=20080613-09:15:34|49=MEFF|

want out out like
8=FIX.4.4
9=197
35=9
34=59518
52=20080613-09:15:34
49=MEFF

Regards
Naveen.
naveenrajAsked:
Who is Participating?
 
mvidasConnect With a Mentor Commented:
Hi Naveen,

You wouldn't really need regular expressions for this; you do have a few options though.

The easiest way would probably be to get a program like notepad2 (freeware) which can put things like carriage returns in their find/replace (strangely enough, using the regex option in their replace dialog).  There are plenty of other programs that can do that as well, I just happen to use notepad2 regularly.

You could also use a simple VBScript file like the attached snippet; simple create a new text document, paste in the attached code, and rename it to something like replacepipes.vbs. Then click/drag your text file into the .vbs file and it will replace the | with a carriage return and line feed.

Let me know if you have any questions
Matt
if wscript.arguments.count = 0 then
 wscript.echo "You must click/drag a file 'into' this vbs file"
 wscript.quit
end if
dim fso, fl, tempstr
set fso=createobject("scripting.filesystemobject")
set fl=fso.opentextfile(wscript.arguments(0))
tempstr=fl.readall
fl.close
tempstr=replace(tempstr,"|",chr(13)&chr(10))
set fl=fso.createtextfile(wscript.arguments(0))
fl.write tempstr
fl.close
set tempstr=nothing
set fl=nothing
set fso=nothing

Open in new window

0
 
ahoffmannCommented:
echo "8=FIX.4.4|9=197|35=9|34=59518|52=20080613-09:15:34|49=MEFF|"|tr '|' '\012'
0
 
naveenrajAuthor Commented:
thanks mvidas.. I cld not get notepad2, but the pgm helped me..
0
 
mvidasCommented:
Happy to help, Naveen! Notepad2 obviously is not a requirement, I mostly use it for it's syntax highlighting as well as it's portability (I keep it on my USB drive to use anywhere, as it does not require an install to use).

Let me know if you need any tweeks or anything
Matt
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.