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
  • 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quick Question PHP - Strip String Pattern 8 50
.net string parse 18 55
Grep - regex - find files matching pattern 2 65
Regex - Ignoring Spaces 7 35
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…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
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…

839 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