Search and Replace ?

B

Big Rick

Hello folks,
Apologies if this is quite basic but I am not a frequent visitor to this
group.

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. It is a search and replace job or a macro?
Hope you can understand this logic.

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

Big Rick

Hello Graham,
Thank you very much for replying. I thought it would be a macro job.
This is very close but not it is not quite working.
On the orginal examples, the result I am getting is

apple pear - banana orange plum
wood metal plastic - glass

As you can see the words are slighty jumbled. Is it me doing something wrong
or is the formula slightly out.
I really appreciate your time and effort.
Please can you help me a little bit further.
--
Big Rick


Graham Mayor said:
A wildcard replace of

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

http://www.gmayor.com/replace_using_wildcards.htm

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


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

Big said:
Hello folks,
Apologies if this is quite basic but I am not a frequent visitor to
this group.

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. It is a search and replace job or a
macro? Hope you can understand this logic.

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