Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Use Regular Expressions to replace words/strings of characters in a text file


From   tashi lama <ltashi32@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Use Regular Expressions to replace words/strings of characters in a text file
Date   Wed, 15 Aug 2012 17:24:21 +0000

Thanx . I did look into file before posting this. I will look into more carefully. Thanx. \
----------------------------------------
> Date: Wed, 15 Aug 2012 18:20:53 +0100
> Subject: Re: st: Use Regular Expressions to replace words/strings of characters in a text file
> From: njcoxstata@gmail.com
> To: statalist@hsphsun2.harvard.edu
>
> No and no. -filefilter- is only part of the answer. If your problems
> were mine, I would be processing the file with -file- statements. You
> would have to read in each line and process it. That could include
> setting markers for when you are in certain parts of the file and are
> prepared to make particular changes.
>
> There is no objection, naturally, to do your doing that with any
> scripting language you know. But my impression is that your problem is
> programmable in Stata.
>
> Nick
>
> On Wed, Aug 15, 2012 at 4:59 PM, tashi lama <ltashi32@hotmail.com> wrote:
> > Thanx. This is great although it seems that its options are limited. Are there ways to pull the followings around
> > 1. filefilter tt1.xml tt2.xml, from("Worksheet") to("") removes worksheet from the file. What if I have a block of characters that I need to remove? Is there a way to say like I want all the characters removed that occur before string table( first occurence of table since there might be multiple strings table in the text)?
> > 2. This might be a redundant of the last part of the first question. Since there are no options in filefilter saying look the pattern only from here to here like in subinstr("fafaa","a","t",1) to mean replace first a or subinstr("fafaa","a","t",.) to mean replace all a, is there a way to do search and replace for only part of the text?
> >
> > Thanx tons..
> > Tashi
> > -----------------------------
> >> Date: Wed, 15 Aug 2012 01:07:39 +0100
> >> Subject: Re: st: Use Regular Expressions to replace words/strings of characters in a text file
> >> From: njcoxstata@gmail.com
> >> To: statalist@hsphsun2.harvard.edu
> >>
> >> -help filefilter-
> >>
> >> Nick
> >>
> >> On Tue, Aug 14, 2012 at 9:18 PM, tashi lama <ltashi32@hotmail.com> wrote:
> >>
> >> > I looked for previous posts and read and still can't find the solution. I could use stata's string functions(regexr, subinstr etc) to search and replace string in a string. But if I have a text file(test1.xml) that I need to run a search and replace on, how do I do it? Putting a text in a local macro( put aside the macro limitation) and using regexr wouldn't be an option because I have to generate a xml file from the dataset.
> >> >
> >> > view test1.xml
> >> >
> >> > <?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
> >> > <?mso-application progid="Excel.Sheet"?>
> >> > <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
> >>
> >> *
> >> * For searches and help try:
> >> * http://www.stata.com/help.cgi?search
> >> * http://www.stata.com/support/statalist/faq
> >> * http://www.ats.ucla.edu/stat/stata/
> > *
> > * For searches and help try:
> > * http://www.stata.com/help.cgi?search
> > * http://www.stata.com/support/statalist/faq
> > * http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/ 		 	   		  
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index