Find and replace

Posted on 2008-06-13
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

Question by:naveenraj
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
LVL 35

Accepted Solution

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
if wscript.arguments.count = 0 then
 wscript.echo "You must click/drag a file 'into' this vbs file"
end if
dim fso, fl, tempstr
set fso=createobject("scripting.filesystemobject")
set fl=fso.opentextfile(wscript.arguments(0))
set fl=fso.createtextfile(wscript.arguments(0))
fl.write tempstr
set tempstr=nothing
set fl=nothing
set fso=nothing

Open in new window

LVL 51

Expert Comment

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

Author Closing Comment

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

Expert Comment

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

Featured Post

Independent Software Vendors: 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

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
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…
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…

623 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