Solved

Find and replace

Posted on 2008-06-13
4
802 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:naveenraj
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 21778414
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 21791703
echo "8=FIX.4.4|9=197|35=9|34=59518|52=20080613-09:15:34|49=MEFF|"|tr '|' '\012'
0
 

Author Closing Comment

by:naveenraj
ID: 31466906
thanks mvidas.. I cld not get notepad2, but the pgm helped me..
0
 
LVL 35

Expert Comment

by:mvidas
ID: 21793403
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now