Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2012, 11:47 AM
jeffk jeffk is offline wildcards in find & replace to reverse word order Windows 7 64bit wildcards in find & replace to reverse word order Office 2007
Novice
wildcards in find & replace to reverse word order
 
Join Date: Jul 2012
Location: North of England, UK
Posts: 29
jeffk is on a distinguished road
Default wildcards in find & replace to reverse word order

I'm trying to use wildcards in Find & Replace to reverse the order of names in a list from surname, first name e.g.

Blogs Fred --> Fred Blogs
Smith John --> John Smith
Doe John
Etc SoForth

I thought that I needed to select ‘Use wildcards’ & type \1 \2 in the ‘Find what’ field & \2 \1 in the ‘Replace with’ field, but when I do this & click ‘Replace All’ I get an error message:

“The Replace with group text contains a number which is out of range”

What's going on here? What am I doing wrong?

*******************************
Edit:
OK, I just tried (<*>) (<*>) in 'find what' & \2 \1 in 'replace with' & it works as long as I select the list of names first, otherwise it applies to everything in the document & messes up the text.

I'm sure that I've done this in the past & it’s worked without me having to select text first, but I can’t remember how..............any suggestions?



Also, I still don't understand why the first way didn't work & what the error message actually means, so any clarification still welcomed!


TIA

Last edited by jeffk; 11-10-2012 at 01:11 PM. Reason: additional info
Reply With Quote
  #2  
Old 11-10-2012, 02:12 PM
gmaxey gmaxey is offline wildcards in find &amp; replace to reverse word order Windows 7 32bit wildcards in find &amp; replace to reverse word order Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,252
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

The error is because you were trying to define groups 1 and 2 in the replace with field that were never defined in the find what field.

If each name in your list of names constitutes a single paragraph then you should have to select the text.


Find: (<*>)( )(<*>)(^13)
Replace With \3\2\1\4
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-11-2012, 01:03 PM
jeffk jeffk is offline wildcards in find &amp; replace to reverse word order Windows 7 64bit wildcards in find &amp; replace to reverse word order Office 2007
Novice
wildcards in find &amp; replace to reverse word order
 
Join Date: Jul 2012
Location: North of England, UK
Posts: 29
jeffk is on a distinguished road
Default

Thanks for that, but could you clarify some things in your answer? Actually, quite a lot of it!

Quote:
Originally Posted by gmaxey View Post
The error is because you were trying to define groups 1 and 2 in the replace with field that were never defined in the find what field.
Defining what I want to find with (<*>) (<*>)

  1. My understanding is that <*> means any single word (compared with e.g. <h*t> which would find hot, hat, hit, etc) so <*> <*> would mean any two adjacent words..........am I right so far?
  2. What exactly do the round brackets ( ) do to <*>?

Quote:
If each name in your list of names constitutes a single paragraph then you should have to select the text.

Find: (<*>)( )(<*>)(^13)

  1. Why the ( ) between (<*>) & (<*>)? When I use (<*>) (<*>) in 'find what' & \2 \1 in 'replace with' it works on the selected text
  2. Why the (^13)? I know it means 'carriage return' i.e. new paragraph, but it doesn't seem to be needed when i use (<*>) (<*>) & \2 \1
  3. If I have to select the text to change then surely the applet’s not actually finding anything – I've already told it where to look, no? That might seem like I'm splitting hairs but if, for example, I had a 50 page doc with multiple instances of names I wanted to reverse (either as lists or within sentences), would I have to manually go through & select each before running find/replace?

Quote:
Replace With \3\2\1\4

  1. Why are the numbers in that order?
  2. Why no spaces between each \number pair?

I know I'm asking a lot of questions there, so any that you feel like answering would be much appreciated. Alternatively, could you point me towards any good tutorials/resources on the topic?
Reply With Quote
  #4  
Old 11-11-2012, 01:47 PM
gmaxey gmaxey is offline wildcards in find &amp; replace to reverse word order Windows 7 32bit wildcards in find &amp; replace to reverse word order Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,252
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

1. Your understanding is correct.
2. The parens define the groups. Group 1 is the first <*>, group 2 is the space separating the words, group 3 it the second <*>, group 4 is the end of paragraph mark.

This: If each name in your list of names constitutes a single paragraph then you should have to select the text.

should have been: If each name in your list of names constitutes a single paragraph then you should "NOT" have to select the text.

1A. By adding the (^13) you will only process two word paragraphs (or only your list and not the rest of the text).

Word 1 Space 2 Word 3 ParagraphMark 4 is rearranged:
3214

http://www.gmayor.com/replace_using_wildcards.htm
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Tags
find & replace, wildcards, word order

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
wildcards in find &amp; replace to reverse word order Word Find and Replace Query bthart Word 1 12-29-2011 12:45 AM
wildcards in find &amp; replace to reverse word order Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
wildcards in find &amp; replace to reverse word order Word 2010: Wildcards Replace tinfanide Word 2 09-10-2011 10:40 AM
Any wildcards search and replace in Powerpoint 2010? tinfanide PowerPoint 0 09-10-2011 02:17 AM
Reverse order of headings throughout Word my_vine_figtree Word VBA 1 08-17-2010 01:46 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:15 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft