Solved

Find and replace

Posted on 2008-06-13
4
807 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…

728 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