How can I build a macro to run on the command-line to do a simple editing of
a text file with a regular pattern to it?
I want to change the text file contents of:
200705230822
200705231341
200705230904
to end up as:
052320070822
052320071341
052320070904

Re: Basic text file edit by Graham

Graham
Thu May 24 00:59:29 CDT 2007

The macro is largely superfluous here
With the patterns shown a simple wildcard search for
(2007)(0523)([0-9]{4})
replace with
\2\1\3
will do the job

If the first part are changeable dates you could use a search string of
([0-9]{4})([0-9]{4})([0-9]{4}) instead (replace string is the same) but I
would prefer to tie the year down more tightly - see
http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


keithkeith wrote:
> How can I build a macro to run on the command-line to do a simple
> editing of a text file with a regular pattern to it?
> I want to change the text file contents of:
> 200705230822
> 200705231341
> 200705230904
> to end up as:
> 052320070822
> 052320071341
> 052320070904



Re: Basic text file edit by keithkeith

keithkeith
Thu May 24 11:56:02 CDT 2007

Thank you, but my data sample was too simplistic. Please consider this
scenario:
I want to change only the two last date fields formatted as yyyymmddhhmm to
mmddyyyy in a text file such as:
2133 AB 200705240233 200705240929
0119 RG 200610011921 200711122300
to:
2133 AB 05242007 05242007
0119 RG 10012006 11122007
where all fields are fixed length, and all field positions are known. Is it
possible to get this macro to run automatically from a command line call?
Thank you for any hints.

"Graham Mayor" wrote:

> The macro is largely superfluous here
> With the patterns shown a simple wildcard search for
> (2007)(0523)([0-9]{4})
> replace with
> \2\1\3
> will do the job
>
> If the first part are changeable dates you could use a search string of
> ([0-9]{4})([0-9]{4})([0-9]{4}) instead (replace string is the same) but I
> would prefer to tie the year down more tightly - see
> http://www.gmayor.com/replace_using_wildcards.htm
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> keithkeith wrote:
> > How can I build a macro to run on the command-line to do a simple
> > editing of a text file with a regular pattern to it?
> > I want to change the text file contents of:
> > 200705230822
> > 200705231341
> > 200705230904
> > to end up as:
> > 052320070822
> > 052320071341
> > 052320070904
>
>
>

Re: Basic text file edit by Doug

Doug
Thu May 24 13:47:28 CDT 2007

You can do it with a wild card search that uses

(<[0-9]{4})([0-9]{4})([0-9]{4}>)

in the Find what control and

\2\1

in the Replace with control

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"keithkeith" <keithkeith@discussions.microsoft.com> wrote in message
news:9BD76AD2-1958-4A67-905A-47B3F2E0BC79@microsoft.com...
> Thank you, but my data sample was too simplistic. Please consider this
> scenario:
> I want to change only the two last date fields formatted as yyyymmddhhmm
> to
> mmddyyyy in a text file such as:
> 2133 AB 200705240233 200705240929
> 0119 RG 200610011921 200711122300
> to:
> 2133 AB 05242007 05242007
> 0119 RG 10012006 11122007
> where all fields are fixed length, and all field positions are known. Is
> it
> possible to get this macro to run automatically from a command line call?
> Thank you for any hints.
>
> "Graham Mayor" wrote:
>
>> The macro is largely superfluous here
>> With the patterns shown a simple wildcard search for
>> (2007)(0523)([0-9]{4})
>> replace with
>> \2\1\3
>> will do the job
>>
>> If the first part are changeable dates you could use a search string of
>> ([0-9]{4})([0-9]{4})([0-9]{4}) instead (replace string is the same) but I
>> would prefer to tie the year down more tightly - see
>> http://www.gmayor.com/replace_using_wildcards.htm
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> keithkeith wrote:
>> > How can I build a macro to run on the command-line to do a simple
>> > editing of a text file with a regular pattern to it?
>> > I want to change the text file contents of:
>> > 200705230822
>> > 200705231341
>> > 200705230904
>> > to end up as:
>> > 052320070822
>> > 052320071341
>> > 052320070904
>>
>>
>>