Find & Replace Question

  • Thread starter Thread starter AA
  • Start date Start date
A

AA

I want to find all occurrences of two spaces, except when the two
spaces follow a period. Haven't been able to figure out how to use
the #not# symbol (!) to do this.

TIA,

Andy
 
In the Find what: field, use:

[!.]{space}{space}

where you actually press the spacebar where I've indicated {space}. You also
need to tick the Use Wildcards option.
 
Jay, a strange thing happened when I tried using [!.]
<space><space> to find two spaces except those preceded
by a period. As I always do each time you or Graham
write anything about the find and replace subject, I
tried applying it by typing a few sentences ending in a
period with two spaces. I also randomly placed two
spaces between some words in the sentences. I
checked "Use Wildcards" also.

When I clicked Find Next, it would first highlight the
last letter of the word preceding the two spaces, and
then the two spaces.

I know it has to be something I'm doing wrong--something
so stupid I'll be embarrassed--but I can't figure it out
on my own. Can you help? And many thanks for all you've
done to further my understanding of Word.

-----Original Message-----
Hi Andy

You have to check the box for "Use wildcards" that appears when you
click the More button in the Find or Replace dialog.

The expression you want is
[!.]<space><space>
where <space> represents a space character.

More info at http://word.mvps.org/FAQs/General/UsingWildcards.htm.

AA said:
I want to find all occurrences of two spaces, except when the two
spaces follow a period. Haven't been able to figure out how to use
the #not# symbol (!) to do this.

TIA,

Andy


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word
.
 
Hi Mary

It isn't strange at all -- that's exactly what the expression is meant
to find. Having found it, you then need to replace it with something,
and that's where the magic happens. :-)

First, read part 8 of
http://word.mvps.org/FAQs/General/UsingWildcards.htm that talks about
using round brackets (also known as parentheses) to mark pieces of the
search string.

I assume that when you find two spaces between words, you then want to
replace them with a single space. To do that, modify the Find What
expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one space.

Mary said:
Jay, a strange thing happened when I tried using [!.]
<space><space> to find two spaces except those preceded
by a period. As I always do each time you or Graham
write anything about the find and replace subject, I
tried applying it by typing a few sentences ending in a
period with two spaces. I also randomly placed two
spaces between some words in the sentences. I
checked "Use Wildcards" also.

When I clicked Find Next, it would first highlight the
last letter of the word preceding the two spaces, and
then the two spaces.

I know it has to be something I'm doing wrong--something
so stupid I'll be embarrassed--but I can't figure it out
on my own. Can you help? And many thanks for all you've
done to further my understanding of Word.

-----Original Message-----
Hi Andy

You have to check the box for "Use wildcards" that appears when you
click the More button in the Find or Replace dialog.

The expression you want is
[!.]<space><space>
where <space> represents a space character.

More info at http://word.mvps.org/FAQs/General/UsingWildcards.htm.

AA said:
I want to find all occurrences of two spaces, except when the two
spaces follow a period. Haven't been able to figure out how to use
the #not# symbol (!) to do this.

TIA,

Andy
 
Jay said:
I assume that when you find two spaces between words, you then want to
replace them with a single space. To do that, modify the Find What
expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one space.

Or ..... you could move the bracket
([!.]<space>)<space>
and replace with
\1

Or...... if you may have more than two spaces
you could search for
([!.]<space>)<space>{1,}

Personally I like to square bracket spaces so they are not missed - but the
square brackets are not necessary to make the search string work.

([!.][ ])[ ]{1,}
and replace with
\1

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
Jay, once more the [!](BUT NOT)threw me, as it does every
single time! I go through the day happily using all I've
learned from you and Graham -- until, that is, I come to
an exclamation point!!!! I won't give up on
understanding how to work with it, though. Hopefully,
just a couple more of these incidents will do the trick.

Thanks you sooooooo much for all your help, Jay.
-----Original Message-----
Hi Mary

It isn't strange at all -- that's exactly what the expression is meant
to find. Having found it, you then need to replace it with something,
and that's where the magic happens. :-)

First, read part 8 of
http://word.mvps.org/FAQs/General/UsingWildcards.htm that talks about
using round brackets (also known as parentheses) to mark pieces of the
search string.

I assume that when you find two spaces between words, you then want to
replace them with a single space. To do that, modify the Find What
expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one space.

Mary said:
Jay, a strange thing happened when I tried using [!.]
<space><space> to find two spaces except those preceded
by a period. As I always do each time you or Graham
write anything about the find and replace subject, I
tried applying it by typing a few sentences ending in a
period with two spaces. I also randomly placed two
spaces between some words in the sentences. I
checked "Use Wildcards" also.

When I clicked Find Next, it would first highlight the
last letter of the word preceding the two spaces, and
then the two spaces.

I know it has to be something I'm doing wrong-- something
so stupid I'll be embarrassed--but I can't figure it out
on my own. Can you help? And many thanks for all you've
done to further my understanding of Word.

-----Original Message-----
Hi Andy

You have to check the box for "Use wildcards" that appears when you
click the More button in the Find or Replace dialog.

The expression you want is
[!.]<space><space>
where <space> represents a space character.

More info at http://word.mvps.org/FAQs/General/UsingWildcards.htm.


I want to find all occurrences of two spaces, except when the two
spaces follow a period. Haven't been able to figure out how to use
the #not# symbol (!) to do this.

TIA,

Andy


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.mvps.org/word
.
 
Graham, thanks more than I can say for your additional
input. I feel so stupid each time I let the exclamation
point in a string throw me, but it never fails to do so.

I'm still not the sharpest tool in the shed when it comes
to find and replace, but I'm a million times better since
reading the wonderful article by you and Jay. I'll keep
trying to better understand the ! .

Thanks again!

-----Original Message-----
Jay said:
I assume that when you find two spaces between words, you then want to
replace them with a single space. To do that, modify the Find What
expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one
space.

Or ..... you could move the bracket
([!.]<space>)<space>
and replace with
\1

Or...... if you may have more than two spaces
you could search for
([!.]<space>)<space>{1,}

Personally I like to square bracket spaces so they are not missed - but the
square brackets are not necessary to make the search string work.

([!.][ ])[ ]{1,}
and replace with
\1

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>



.
 
The principle of searching is to look for a unique string.
Here you are looking for two spaces but not if those two spaces follow a
full stop (period)
Essentially the [!.] means look for any character except a full stop
(period). i.e. the exclamation mark means ignore this (or these)
character(s) in this bracketed section. Thus you can exclude characters from
the search string.
That extra character remains part of the search string, but you want to keep
that character, so you mark it with round brackets
to enable you to put back the extra leading character in your replacement
string using the \1 , which means replace the first set of bracketed
characters.

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>


Graham, thanks more than I can say for your additional
input. I feel so stupid each time I let the exclamation
point in a string throw me, but it never fails to do so.

I'm still not the sharpest tool in the shed when it comes
to find and replace, but I'm a million times better since
reading the wonderful article by you and Jay. I'll keep
trying to better understand the ! .

Thanks again!

-----Original Message-----
Jay said:
I assume that when you find two spaces between words, you then want
to replace them with a single space. To do that, modify the Find
What expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one space.

Or ..... you could move the bracket
([!.]<space>)<space>
and replace with
\1

Or...... if you may have more than two spaces
you could search for
([!.]<space>)<space>{1,}

Personally I like to square bracket spaces so they are not missed -
but the square brackets are not necessary to make the search string
work.

([!.][ ])[ ]{1,}
and replace with
\1

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>



.
 
Your statement "That extra character remains part of the
search string, but you want to keep that character, so
you mark it with round brackets to enable you to put back
the extra leading character in your replacement" was what
I needed to hear and it hit the spot. I'm gonna make you
proud yet!

Thanks so very much, Graham.

Your grateful Ft. Lauderdale fan,
Mary
-----Original Message-----
The principle of searching is to look for a unique string.
Here you are looking for two spaces but not if those two spaces follow a
full stop (period)
Essentially the [!.] means look for any character except a full stop
(period). i.e. the exclamation mark means ignore this (or these)
character(s) in this bracketed section. Thus you can exclude characters from
the search string.
That extra character remains part of the search string, but you want to keep
that character, so you mark it with round brackets
to enable you to put back the extra leading character in your replacement
string using the \1 , which means replace the first set of bracketed
characters.

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>


Graham, thanks more than I can say for your additional
input. I feel so stupid each time I let the exclamation
point in a string throw me, but it never fails to do so.

I'm still not the sharpest tool in the shed when it comes
to find and replace, but I'm a million times better since
reading the wonderful article by you and Jay. I'll keep
trying to better understand the ! .

Thanks again!

-----Original Message-----
Jay Freedman wrote:
I assume that when you find two spaces between words, you then want
to replace them with a single space. To do that, modify the Find
What expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one space.

Or ..... you could move the bracket
([!.]<space>)<space>
and replace with
\1

Or...... if you may have more than two spaces
you could search for
([!.]<space>)<space>{1,}

Personally I like to square bracket spaces so they are not missed -
but the square brackets are not necessary to make the search string
work.

([!.][ ])[ ]{1,}
and replace with
\1

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>



.


.
 
I'm happy you found it all useful :)

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>


Your statement "That extra character remains part of the
search string, but you want to keep that character, so
you mark it with round brackets to enable you to put back
the extra leading character in your replacement" was what
I needed to hear and it hit the spot. I'm gonna make you
proud yet!

Thanks so very much, Graham.

Your grateful Ft. Lauderdale fan,
Mary
-----Original Message-----
The principle of searching is to look for a unique string.
Here you are looking for two spaces but not if those two spaces
follow a full stop (period)
Essentially the [!.] means look for any character except a full stop
(period). i.e. the exclamation mark means ignore this (or these)
character(s) in this bracketed section. Thus you can exclude
characters from the search string.
That extra character remains part of the search string, but you want
to keep that character, so you mark it with round brackets
to enable you to put back the extra leading character in your
replacement string using the \1 , which means replace the first set
of bracketed characters.

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>


Graham, thanks more than I can say for your additional
input. I feel so stupid each time I let the exclamation
point in a string throw me, but it never fails to do so.

I'm still not the sharpest tool in the shed when it comes
to find and replace, but I'm a million times better since
reading the wonderful article by you and Jay. I'll keep
trying to better understand the ! .

Thanks again!


-----Original Message-----
Jay Freedman wrote:
I assume that when you find two spaces between words, you then
want to replace them with a single space. To do that, modify the
Find What expression to

([!.])<space><space>

and use the Replace With expression

\1<space>

The \1 part will be filled in with whatever character matched the
[!1], and the two spaces will be replaced with one space.

Or ..... you could move the bracket
([!.]<space>)<space>
and replace with
\1

Or...... if you may have more than two spaces
you could search for
([!.]<space>)<space>{1,}

Personally I like to square bracket spaces so they are not missed -
but the square brackets are not necessary to make the search string
work.

([!.][ ])[ ]{1,}
and replace with
\1

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

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>



.


.
 
Back
Top