Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2014, 09:41 AM
Ulodesk Ulodesk is offline Where is the error in my wildcard search? Windows 7 64bit Where is the error in my wildcard search? Office 2013
Word 2013 Expert Cert
Where is the error in my wildcard search?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Where is the error in my wildcard search?

In continued experimenting with wildcards, I set the following problem for myself:


Given this list,

Daryl Paer 2013
Fred Marker 240
Gary Kenda 23096
Joan Laer 23
John Jones 9012

find only the lines with 4-digit numbers. The replace would then put the number in front of the name, which should be, I think, \3 \1 \2^p. However, after many attempts, I am still not able to get the find argument to work properly. Here is the one that I think should work:

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

The key, of course, is the third term. I thought this would find only the lines with four-digit numbers, but, although it finds Line 1, the subsequent clicks on Find next merely diminish the selected area by one character each time, from the left, for several, and then select the rest of the list as well! Adding parentheses around the ^13 makes no difference.

I don't understand the jump past the line return at the end of Line 1, to select the rest of the list, nor how to eliminate the one-character diminishment routine.

Who says the brain is just a computer? Not I, and thank goodness! But someone who has bridged the gap more successfully may surely help here.
Reply With Quote
  #2  
Old 06-24-2014, 10:07 AM
Cosmo Cosmo is offline Where is the error in my wildcard search? Windows Vista Where is the error in my wildcard search? Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

There may be a better solution, but the following works for me:

(<[A-Za-z]{1,}>) (<[A-Za-z]{1,}>) (<[0-9]{4}>)^13
Reply With Quote
  #3  
Old 06-24-2014, 10:12 AM
Ulodesk Ulodesk is offline Where is the error in my wildcard search? Windows 7 64bit Where is the error in my wildcard search? Office 2013
Word 2013 Expert Cert
Where is the error in my wildcard search?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Search

Thank you. It does work. Any idea why mine fails as indicated?

Ulodesk
Reply With Quote
  #4  
Old 06-24-2014, 10:24 AM
Cosmo Cosmo is offline Where is the error in my wildcard search? Windows Vista Where is the error in my wildcard search? Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

I'm far from an expert in using Wildcard terminology (I'm much more used to Regular Expressions), but I do know that the '*' character can give you results that you don't expect - since it means any number of characters. It matches the first row of your text, and each successive search (excluding one character at a time) also is a match. Then the next match afterwards is all of your text (since a space is a match for the * character) since the last match is to the final 9012 (all of the preceeding text will match that - any characters followed by a space, followed by any characters, followed by another space, followed by your 4 digit number, followed by a return)
Reply With Quote
  #5  
Old 06-24-2014, 04:53 PM
macropod's Avatar
macropod macropod is offline Where is the error in my wildcard search? Windows 7 32bit Where is the error in my wildcard search? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could also use:
Find = ([!0-9^13]@)( )(<[0-9]{4})^13 or ([!^13 ]@ [! ]@)( )([0-9]{4})^13
Replace = \3\2\1^p
The reason '(*) (*) (<[0-9]{4}>)^13' doesn't work, is that * represents a string of any content and length. That content could include paragraph breaks and spaces, which is self-defeating.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 06-25-2014, 06:34 AM
Ulodesk Ulodesk is offline Where is the error in my wildcard search? Windows 7 64bit Where is the error in my wildcard search? Office 2013
Word 2013 Expert Cert
Where is the error in my wildcard search?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default

Ah! I had been thinking, for some reason or, better, lack thereof, that the line break would be an exception. As the Germans say, alles klar.

Thanks.
Reply With Quote
  #7  
Old 06-25-2014, 07:04 AM
Ulodesk Ulodesk is offline Where is the error in my wildcard search? Windows 7 64bit Where is the error in my wildcard search? Office 2013
Word 2013 Expert Cert
Where is the error in my wildcard search?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default A question about space

Hi, Paul. Looking more closely at your second variation,

([!^13 ]@ [! ]@)( )([0-9]{4})^13

I am perplexed about the space after the line break in the first brackets. Since you specify ignoring a space in the next item in this first term, why is it necessary in both places?

Thanks.
Reply With Quote
  #8  
Old 06-25-2014, 06:04 PM
macropod's Avatar
macropod macropod is offline Where is the error in my wildcard search? Windows 7 32bit Where is the error in my wildcard search? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The '[!^13 ]@ ' says to find a string that contains neither a paragraph break no a space, followed by a space.
The '([!^13 ]@ [! ]@)( )' says basically the same thing - but to do it twice and to remember what we've found.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 06-30-2014, 07:15 AM
Ulodesk Ulodesk is offline Where is the error in my wildcard search? Windows 7 64bit Where is the error in my wildcard search? Office 2013
Word 2013 Expert Cert
Where is the error in my wildcard search?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default A further exploration of search syntax mystery

In my continuing quest for fluency in this domain, another question has arisen.
Here is the working wildcard search Paul provided for my list of "Name Name Year" to find the (4-digit) years and move them. The second is my attempt at an alternate.

([!0-9^13]@)( )(<[0-9]{4})^13

([!0-9^13]{1,})( )(<[0-9]{4})^13

It would seem to me that "one or more" represented by the @ symbol could be substituted with {1,} which is "at least one". Yet, the second doesn't work, nor does {2,}. However, the following, which has no specification in the same place, does work:

([!0-9^13])( )(<[0-9]{4})^13

(although it selects only the last letter of the second name, up to the line return, rather than the entire paragraph up to the line return, as Paul's does).

What prevent the {1,} from working?

Thank,s as always.
Reply With Quote
  #10  
Old 06-30-2014, 12:39 PM
Robert2 Robert2 is offline Where is the error in my wildcard search? Windows 8 Where is the error in my wildcard search? Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 165
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

This is because the repetition counters @ and {1,} behave differently. @ performs “lazy matching” and is happy with one instance of the preceding character or character set. {1,} performs “greedy matching” and gobbles up as many instances of the preceding character or character set as it can.

Let’s take “Daryl Paer 2013” as an example.

([!0-9^13]@)( )

catches “Daryl ” first, then goes on to catch “Paer ” (and goes on until it finds the final 4 digits and paragraph end mark).

On the other hand,

([!0-9^13]{1,})

catches “Daryl Paer ” directly. This is why “([!0-9^13]{1,})( )(<[0-9]{4})^13” does not work. There is no need to search for the space character preceding the 4 digits. It has already been found by ([!0-9^13]{1,}).

Now

([!0-9^13]{1,})( )(<[0-9]{4})^13

would work if you removed the space character from the search pattern:

([!0-9^13]{1,})(<[0-9]{4})^13

With such a search string, the Replace pattern itself needs to insert the space character after the 4 digits:

\2^32\1^p

Note that you could also use the following pattern:

Find:

([!0-9^13]@)(<[0-9]{4})^13

Replace:

\2^32\1^p

By the way, ^32 is the code for a space character.

HTH.
Reply With Quote
  #11  
Old 06-30-2014, 01:46 PM
Ulodesk Ulodesk is offline Where is the error in my wildcard search? Windows 7 64bit Where is the error in my wildcard search? Office 2013
Word 2013 Expert Cert
Where is the error in my wildcard search?
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Thanks

Thank you, sir. Much obliged.

Ulodesk
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the error in my wildcard search? Wildcard search fails in table NobodysPerfect Word VBA 4 06-11-2014 11:02 AM
Change characters outside a wildcard while keeping wildcard results nymusicman Word VBA 2 04-10-2014 08:17 AM
Where is the error in my wildcard search? Tricky wildcard search NobodysPerfect Word 10 03-19-2014 04:29 AM
Search for date and then apply mutliple search criteria in huge dataset maxtymo Excel 2 12-01-2013 04:52 AM
Wildcard search help. Kempston Word 0 11-13-2009 03:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:42 AM.


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