Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2012, 05:33 AM
grapes grapes is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2003
Novice
Problem with find and replace
 
Join Date: Dec 2012
Posts: 6
grapes is on a distinguished road
Default Problem with find and replace

Hello this is my situation. I have a very long text which contains a lot of references. Here is a example:




Microsoft Windows is a series of graphical interface (Jhon Smith, 1986). operating systems developed, marketed, and sold by Microsoft (Richard Hale, 1946 and Jhon Smith, 1990).

So I need a formula which can find and delete any string of characters between parentheses, but which also must contain a 4 digit number (a year date which always starts with 19). To make things easier (because () are wildcard characters) i changed the ( for Ö, and the ) for Ü in all the document.
I tried different things, like Ö*[0-9]{4}*Ü, but i get always the same problem, it does not select one by one:

Microsoft Windows is a series of graphical interface (Jhon Smith, 1986) operating systems developed, marketed, and sold by Microsoft (Richard Hale, 1946 and Jhon Smith, 1990).

Any help will be appreciated and sorry about my bad english.
Reply With Quote
  #2  
Old 12-10-2012, 11:50 PM
macropod's Avatar
macropod macropod is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

From what you've described it seems your wildcard Find/Replace should use:
Find = \(*[0-9]{4}*\)
Replace = () - or perhaps nothing.

You mention year dates beginning with '19', but what about '20'? If only year dates beginning the '19' are valid, then use:
Find = \(*19[0-9]{2}*\)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-11-2012, 03:40 AM
grapes grapes is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2003
Novice
Problem with find and replace
 
Join Date: Dec 2012
Posts: 6
grapes is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
From what you've described it seems your wildcard Find/Replace should use:
Find = \(*[0-9]{4}*\)
Yes thanks, thats exactly the expression I tried before, the problem is that it matches more than one result. Please check what happens to this text when you apply \(*[0-9]{4}*\)

Other people believe they are not at all in control of what happens
to them (these people feel like they are merely riding a space ship
controlled by a control center far away). It seems to them that
external forces, such as other people, fate, luck or chance, are
responsible for what happens to them. Such people are
"externalizers." At first, it may seem like externalizers would be
hopeless, scared, and paranoid. Some are but others are optimistic
and blissful because they believe "things happen for the best," life is
guided by a kind fate and/or by God's will, or a benevolent God is
looking out for them.
Many learning theorists, such as B. F. Skinner, believe that forces
in the environment (including previously learned response habits
based on rewards and punishment) determine what happens in our
lives. This eliminates free will (meaning an undetermined choice,one
which is of our doing at this moment and not explained by the
environment or our past experience). Yet, many if not most people feel
as if they make "free" choices and are in control. How could we get the
belief that we are directing our lives if everything were determined by
external factors (which I don't believe)? Because it "seems like" we are
planning and directing our lives, at least some parts of it. I believe that
is an accurate perception, but, in addition, research has shown that in
certain circumstances there is a remarkable tendency to believe we
are in control when we aren't. For instance, Langer sold $1
lottery tickets. One half got a randomly selected ticket; the other half
got to select their own ticket. Then she asked them how much they
would sell their ticket for. The first group would take on average
$1.96. The second group wanted an average of $8.67, presumably
asking much more because they believed it was more likely to win. So
it is quite possible to believe you are in control when you aren't. (And,
as we saw in Seligman's helplessness research in chapter 6, the
opposite may be true too: dogs and many humans too may believe
they are out of control when they aren't. More on this later.)
Why might a person believe they have control when they haven't?
This view provides hope (of winning the lottery, etc.) and makes the
world less scary and more predictable and comfortable. Indeed,
considerable evidence suggests we are more effective, more
responsible, and happier when we feel we are partially in control, i.e.
have made the decisions and carried out the plans for changing things
(Deaux and Wrightsman, 1984). But, of course, it is usually impossible
to know exactly how much of our good fortune is due to our efforts
and how much is due to others, fate, or chance. It is, to some extent,
a matter of "beliefs."

Obviously the * is messing things up. But I dont know, I would need an expression that stop after the first result.
Reply With Quote
  #4  
Old 12-11-2012, 04:10 AM
macropod's Avatar
macropod macropod is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

Your specification was:
Quote:
So I need a formula which can find and delete any string of characters between parentheses, but which also must contain a 4 digit number
The wildcard Find/Replace code I posted does that.

If you only want to replace the first instance, use 'Replace', not 'Replace All'. And if you want the choice of which expressions to replace, click 'Find' to go to the first one, then 'Replace' if you want to replace it, else 'Find' to go to the next one. Continue, using 'Replace' or 'Find' each time, as appropriate.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-12-2012, 12:55 AM
grapes grapes is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2003
Novice
Problem with find and replace
 
Join Date: Dec 2012
Posts: 6
grapes is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The wildcard Find/Replace code I posted does that.
You're right Paul. I forgot to specify that the string inside the parentheses must not contain parentheses. Otherwise I get unwanted results:

Find = \(*[0-9]{4}*\)

This view provides hope (of winning the lottery, etc.) and makes the
world less scary and more predictable and comfortable. Indeed,
considerable evidence suggests we are more effective, more
responsible, and happier when we feel we are partially in control, i.e.
have made the decisions and carried out the plans for changing things
(Deaux and Wrightsman, 1984)
. But, of course, it is usually impossible
to know exactly how much of our good fortune is due to our efforts
and how much is due to others, fate, or chance. It is, to some extent,
a matter of "beliefs."

Thanks.
Reply With Quote
  #6  
Old 12-12-2012, 03:36 AM
macropod's Avatar
macropod macropod is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

Try:
Find = \([!\)]@[0-9]{4}*\)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 12-12-2012, 06:48 AM
grapes grapes is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2003
Novice
Problem with find and replace
 
Join Date: Dec 2012
Posts: 6
grapes is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try:
Find = \([!\)]@[0-9]{4}*\)
This does not work either

Find = \([!\(]@[0-9]{4}*\)

Alcoholic Anonymous (AA), has
been essentially the only treatment available since the 1930's until this
decade. Even now, AA is the treatment commonly recommended,
especially by medical institutions. AA and the 12-step programs have,
indeed, helped millions, but there are a lot of people they don't help
(Kasl, 1992). The relapse rate of AA members is over 70%.

I will keep trying.
Reply With Quote
  #8  
Old 12-12-2012, 02:01 PM
macropod's Avatar
macropod macropod is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

It works for me. It finds '(Kasl, 1992)' but not '(AA)'. That conforms to your specifications (ie that the content between the parentheses must contain a 4-digit number). In what sense isn't it working for you?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 12-13-2012, 01:26 AM
grapes grapes is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2003
Novice
Problem with find and replace
 
Join Date: Dec 2012
Posts: 6
grapes is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
It works for me. It finds '(Kasl, 1992)' but not '(AA)'. That conforms to your specifications (ie that the content between the parentheses must contain a 4-digit number). In what sense isn't it working for you?
The first search it finds from '(AA)' to '(Kasl, 1992)' The highlighted in blue in my previous post. The second and third matches are ok, it finds '(AA)' and then '(Kasl, 1992)'

I will do some trial and error with different expressions and see what happens. I have the idea of the right expression, but the sintax of it is a little tricky. Thanks for your help Paul.
Reply With Quote
  #10  
Old 12-13-2012, 01:46 AM
macropod's Avatar
macropod macropod is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

That suggests you're not using the Find code as posted. As I said, it works for me. Let me explain what the '\([!\)]@[0-9]{4}*\)' represents:
1. '\(' - the string must begin with an opening parenthesis
2. '[!\)]@' - after the opening parenthesis must be a string of any length consisting of characters other than a closing parenthesis. This prevents a range like '(AA) ... (Kasl, 1992)' being found.
3. '(]@[0-9]{4}' - after the string of any length consisting of characters other than a closing parenthesis, there must be a 4-digit number. This prevents a range like '(AA)' being found.
4. '*\)' - after the 4-digit number can be a string of any length terminating in a closing parenthesis.

You could try adding some redundancy:
Find = \([!\(\)]@[0-9]{4}*\)
The effect of this on the above explanation is:
2. '[!\(\)]@' - after the opening parenthesis must be a string of any length consisting of characters other than an opening or closing parenthesis.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 12-13-2012, 02:54 PM
grapes grapes is offline Problem with find and replace Windows 7 64bit Problem with find and replace Office 2003
Novice
Problem with find and replace
 
Join Date: Dec 2012
Posts: 6
grapes is on a distinguished road
Default

Finally I found a expression that works, at least for my particular case.
Its your expression but without the '*'

Find = \([!\(\)]@[0-9]{4}\)

I thought a little and I noticed that fortunately for me all the strings I want to delete ends with '####)' So the '*' is not necessary.
Thanks for you help Paul.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
find & replace with vba goodhouse PowerPoint 2 06-10-2012 12:10 AM
Problem with find and replace Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Problem with find and replace Is there a way to use "find/replace" to find italics words? slayda Word 3 09-14-2011 02:16 PM
Problem with find and replace Find/Replace Brackets Problem fatso Word 2 08-04-2011 11:34 AM
Problem with find and replace Help with find and replace or query and replace shabbaranks Excel 4 03-19-2011 08:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:19 PM.


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