Search and Replace help.

B

Big Rick

Hello Folks
I have a document with many thousands of lines. All lines are 12 or so words
each with a "-" somewhere in the middle. I want to be able to swap the words
around to the other side of the "-". The lenght and the amount of the words
can vary.

e.g. if I have:-
apple banana - pear orange plum
wood metal glass - plastic

I want the result to be:-
pear orange plum - apple banana
plastic - wood metal glass

This must work on selected text only as only 3/4 of the document needs
changing, not the whole lot.
Mr Graham Mayor gave me following but it is not quite working. It is only
swapping around the words either side of the " - "

A wildcard replace of
(<[a-zA-Z]@>)( - )(<[a-zA-Z]@>)
with
\3\2\1
on the selected text should work.

So please can Graham or someone else help me out a bit further.

Your help is and always has been very much appreciated.
Thanking you in anticipation.
 
J

JoAnn Paules

I know what I would do but it's not going to be the way the Wordies would do
it. I'd dump those lines int Excel, swap them around, then put them back
into Word.

--

JoAnn Paules
MVP Microsoft [Publisher]

~~~~~
How to ask a question
http://support.microsoft.com/KB/555375
 
G

Graham Mayor

Assuming each line ends a paragraph, replace
(<[a-zA-Z ]@>)( - )(<[a-zA-Z ]@)^13
with
\3\2\1^p
instead
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Big Rick

Absolutely, superb.
Thank you very much.
--
Big Rick


Graham Mayor said:
Assuming each line ends a paragraph, replace
(<[a-zA-Z ]@>)( - )(<[a-zA-Z ]@)^13
with
\3\2\1^p
instead
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Big said:
Hello Folks
I have a document with many thousands of lines. All lines are 12 or
so words each with a "-" somewhere in the middle. I want to be able
to swap the words around to the other side of the "-". The lenght and
the amount of the words can vary.

e.g. if I have:-
apple banana - pear orange plum
wood metal glass - plastic

I want the result to be:-
pear orange plum - apple banana
plastic - wood metal glass

This must work on selected text only as only 3/4 of the document needs
changing, not the whole lot.
Mr Graham Mayor gave me following but it is not quite working. It is
only swapping around the words either side of the " - "

A wildcard replace of
(<[a-zA-Z]@>)( - )(<[a-zA-Z]@>)
with
\3\2\1
on the selected text should work.

So please can Graham or someone else help me out a bit further.

Your help is and always has been very much appreciated.
Thanking you in anticipation.
 
B

Big Rick

Absolutely superb. Thank you very much.
Your webite was a great help in tweaking it to include other characters.
--
Big Rick


Graham Mayor said:
Assuming each line ends a paragraph, replace
(<[a-zA-Z ]@>)( - )(<[a-zA-Z ]@)^13
with
\3\2\1^p
instead
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Big said:
Hello Folks
I have a document with many thousands of lines. All lines are 12 or
so words each with a "-" somewhere in the middle. I want to be able
to swap the words around to the other side of the "-". The lenght and
the amount of the words can vary.

e.g. if I have:-
apple banana - pear orange plum
wood metal glass - plastic

I want the result to be:-
pear orange plum - apple banana
plastic - wood metal glass

This must work on selected text only as only 3/4 of the document needs
changing, not the whole lot.
Mr Graham Mayor gave me following but it is not quite working. It is
only swapping around the words either side of the " - "

A wildcard replace of
(<[a-zA-Z]@>)( - )(<[a-zA-Z]@>)
with
\3\2\1
on the selected text should work.

So please can Graham or someone else help me out a bit further.

Your help is and always has been very much appreciated.
Thanking you in anticipation.
 
G

Graham Mayor

You are welcome :)

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Big said:
Absolutely superb. Thank you very much.
Your webite was a great help in tweaking it to include other
characters.
Assuming each line ends a paragraph, replace
(<[a-zA-Z ]@>)( - )(<[a-zA-Z ]@)^13
with
\3\2\1^p
instead
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Big said:
Hello Folks
I have a document with many thousands of lines. All lines are 12 or
so words each with a "-" somewhere in the middle. I want to be able
to swap the words around to the other side of the "-". The lenght
and the amount of the words can vary.

e.g. if I have:-
apple banana - pear orange plum
wood metal glass - plastic

I want the result to be:-
pear orange plum - apple banana
plastic - wood metal glass

This must work on selected text only as only 3/4 of the document
needs changing, not the whole lot.
Mr Graham Mayor gave me following but it is not quite working. It is
only swapping around the words either side of the " - "

A wildcard replace of
(<[a-zA-Z]@>)( - )(<[a-zA-Z]@>)
with
\3\2\1
on the selected text should work.

So please can Graham or someone else help me out a bit further.

Your help is and always has been very much appreciated.
Thanking you in anticipation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top