Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2018, 12:12 PM
wardw wardw is offline Wildcard replace any string in context with a specified string Windows 7 64bit Wildcard replace any string in context with a specified string Office 2007
Advanced Beginner
Wildcard replace any string in context with a specified string
 
Join Date: Oct 2012
Posts: 56
wardw is on a distinguished road
Default Wildcard replace any string in context with a specified string

I'm working with OCR'd documents with frequently repeated titles, like "CBS EVENING NEWS WITH WALTER". For cases where WITH is completely misspelled, as in "CBS EVENING NEWS BIFG WALTER", I need to find that string and replace it with WITH. Pseudocode would be something like "find NEWS followed by any single word except WITH, followed by WALTER. Replace with NEWS WITH WALTER".



I'm having no luck specifying "any string except this", like "CBS EVENING NEWS [!WITH] WALTER". Search just says it's not found.

Is it possible to specify a particular string using [!], or does it work only for single characters?
Reply With Quote
  #2  
Old 05-06-2018, 03:42 PM
macropod's Avatar
macropod macropod is offline Wildcard replace any string in context with a specified string Windows 7 64bit Wildcard replace any string in context with a specified string Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 use a wildcard Find/Replace where:
Find = (CBS EVENING NEWS )*( WALTER)
Replace = \1WITH\2
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-06-2018, 03:48 PM
wardw wardw is offline Wildcard replace any string in context with a specified string Windows 7 64bit Wildcard replace any string in context with a specified string Office 2007
Advanced Beginner
Wildcard replace any string in context with a specified string
 
Join Date: Oct 2012
Posts: 56
wardw is on a distinguished road
Default

Well, that certainly works; thanks very much, Paul!
Reply With Quote
  #4  
Old 05-06-2018, 04:23 PM
Guessed's Avatar
Guessed Guessed is offline Wildcard replace any string in context with a specified string Windows 10 Wildcard replace any string in context with a specified string Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If this is a search and replace activity, you don't NEED to exclude the correct word since you would be replacing it with itself.
Find: EVENING NEWS ???? WALTER
Replace with: EVENING NEWS WITH WALTER

To examine why the search you did isn't working.
1. [!WITH] will be looking for a single character other than those 4 letters. If you wanted a 4 digit word then you would need [!WITH]{4}
2. However that fix wouldn't work as expected because your search would exclude any four digit word that happens to contain any one of those letters. Since 'I' appears in BIFG it would be missed in the search.
3. It still wouldn't work if you got specific about the placement of excluded characters looked for [!W][!I][!T][!H] because if the second letter is I as per your example, that won't get found.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 05-06-2018, 05:49 PM
macropod's Avatar
macropod macropod is offline Wildcard replace any string in context with a specified string Windows 7 64bit Wildcard replace any string in context with a specified string Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Quote:
Originally Posted by Guessed View Post
If this is a search and replace activity, you don't NEED to exclude the correct word since you would be replacing it with itself.
Find: EVENING NEWS ???? WALTER
Replace with: EVENING NEWS WITH WALTER
The advantage of using * instead of ???? is that the OCR process may have created more or fewer than 4 characters instead of WITH. The disadvantage, is that is may make false matches (e.g. EVENING NEWS WITHOUT WALTER)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 05-06-2018, 06:35 PM
Guessed's Avatar
Guessed Guessed is offline Wildcard replace any string in context with a specified string Windows 10 Wildcard replace any string in context with a specified string Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Another disadvantage of * is that the search is not restricting itself to a single word so there is the danger of
EVENING NEWS BY HERBERT blah blah multiple paragraphs blah blah EVENING NEWS WITH WALTER
would become
EVENING NEWS WITH WALTER
so you would lose a lot of content you possibly didn't want to.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 05-06-2018, 06:53 PM
macropod's Avatar
macropod macropod is offline Wildcard replace any string in context with a specified string Windows 7 64bit Wildcard replace any string in context with a specified string Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

True, in which case one might replace the * in the F/R Find I posted with *{3,6}, for example, to limit the wildcard matches to strings with 3-6 characters.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 05-07-2018, 09:13 AM
wardw wardw is offline Wildcard replace any string in context with a specified string Windows 7 64bit Wildcard replace any string in context with a specified string Office 2007
Advanced Beginner
Wildcard replace any string in context with a specified string
 
Join Date: Oct 2012
Posts: 56
wardw is on a distinguished road
Default

Thank you, Andrew and Paul; I now know a lot more about F/R exclusions. I'll try both the * and ???? methods to see which is best in my situation.
Reply With Quote
Reply

Tags
wildcard searches

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wildcard replace any string in context with a specified string Replace characters in a string Anthon Excel Programming 1 11-03-2016 12:48 AM
How to find all string within string. PRA007 Word VBA 18 02-12-2016 08:11 PM
Wildcard replace any string in context with a specified string Find Multiple Wildcard string and Highlight PRA007 Word VBA 2 10-17-2015 01:07 AM
Wildcard replace any string in context with a specified string Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM
Extract from String using Wildcard whousedmy Word 0 05-21-2009 01:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:23 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