Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
[email protected] tante.v@gmail.com is offline
external usenet poster
 
Posts: 3
Default Need help with Find and Replace using Regular Expressions

I'm trying to search for instances of "St" in the middle of a word
(uppercase S, lowercase t) so that I can use Find and Replace to
correct the casing (as in firSt, laSt). I've come up with the
following regular expression string which almost works:

[!()( )(")(')^13]St

It was necessary to add so many exclusions to prevent it from giving
me "St" at the beginning of a word or line, after initial quotes, etc.

So, this works well except that it highlights not just "St", but the
letter preceding it: "rSt", "aSt". This prevents me from using Find
and Replace to replace "St" with "st". I can't seem to get a wildcard
like
?st to work in the Replace box, so I'm stuck. What is it about my
regex string that says "return the letter preceding the string I'm
looking for too"?

Thanks in advance.
  #3   Report Post  
Posted to microsoft.public.word.newusers
[email protected] tante.v@gmail.com is offline
external usenet poster
 
Posts: 3
Default Need help with Find and Replace using Regular Expressions

Wow...that works great, and it's a lot simpler than what I was doing.
Can you help me to understand what the syntax is saying, so I get a
better idea of how to use regex?

Is it:

search for lowercase (a to z) or uppercase (A-Z)...meaning some letter
precedes the St...?

And could you explain what \1st means?

Thanks a lot! This is going to make my work go much more quickly.


On Aug 19, 9:10*am, "Graham Mayor" wrote:
How about replace
([a-zA-Z])St
with
\1st
?

--

Graham Mayor - *Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org




wrote:
I'm trying to search for instances of "St" in the middle of a word
(uppercase S, lowercase t) so that I can use Find and Replace to
correct the casing (as in firSt, laSt). I've come up with the
following regular expression string which almost works:


[!()( )(")(')^13]St


It was necessary to add so many exclusions to prevent it from giving
me "St" at the beginning of a word or line, after initial quotes, etc.


So, this works well except that it highlights not just "St", but the
letter preceding it: "rSt", "aSt". This prevents me from using Find
and Replace to replace "St" with "st". I can't seem to get a wildcard
like
?st to work in the Replace box, so I'm stuck. What is it about my
regex string that says "return the letter preceding the string I'm
looking for too"?


Thanks in advance.- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Need help with Find and Replace using Regular Expressions

wrote:
Wow...that works great, and it's a lot simpler than what I was doing.
Can you help me to understand what the syntax is saying, so I get a
better idea of how to use regex?

Is it:

search for lowercase (a to z) or uppercase (A-Z)...meaning some letter
precedes the St...?


yes

And could you explain what \1st means?


replace with the first bracketed item \1 and add st

See
http://www.gmayor.com/replace_using_wildcards.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




On Aug 19, 9:10 am, "Graham Mayor" wrote:
How about replace
([a-zA-Z])St
with
\1st
?

--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org




wrote:
I'm trying to search for instances of "St" in the middle of a word
(uppercase S, lowercase t) so that I can use Find and Replace to
correct the casing (as in firSt, laSt). I've come up with the
following regular expression string which almost works:


[!()( )(")(')^13]St


It was necessary to add so many exclusions to prevent it from giving
me "St" at the beginning of a word or line, after initial quotes,
etc.


So, this works well except that it highlights not just "St", but the
letter preceding it: "rSt", "aSt". This prevents me from using Find
and Replace to replace "St" with "st". I can't seem to get a
wildcard like
?st to work in the Replace box, so I'm stuck. What is it about my
regex string that says "return the letter preceding the string I'm
looking for too"?


Thanks in advance.- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.word.newusers
[email protected] tante.v@gmail.com is offline
external usenet poster
 
Posts: 3
Default Need help with Find and Replace using Regular Expressions

On Aug 19, 11:24*am, "Graham Mayor" wrote:
wrote:
Wow...that works great, and it's a lot simpler than what I was doing.
Can you help me to understand what the syntax is saying, so I get a
better idea of how to use regex?


Is it:


search for lowercase (a to z) or uppercase (A-Z)...meaning some letter
precedes the St...?


yes

And could you explain what \1st means?


replace with the first bracketed item \1 and add st

Seehttp://www.gmayor.com/replace_using_wildcards.htm

--

Graham Mayor - *Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org






On Aug 19, 9:10 am, "Graham Mayor" wrote:
How about replace
([a-zA-Z])St
with
\1st
?


--

Graham Mayor - Word MVP


My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


wrote:
I'm trying to search for instances of "St" in the middle of a word
(uppercase S, lowercase t) so that I can use Find and Replace to
correct the casing (as in firSt, laSt). I've come up with the
following regular expression string which almost works:


[!()( )(")(')^13]St


It was necessary to add so many exclusions to prevent it from giving
me "St" at the beginning of a word or line, after initial quotes,
etc.


So, this works well except that it highlights not just "St", but the
letter preceding it: "rSt", "aSt". This prevents me from using Find
and Replace to replace "St" with "st". I can't seem to get a
wildcard like
?st to work in the Replace box, so I'm stuck. What is it about my
regex string that says "return the letter preceding the string I'm
looking for too"?


Thanks in advance.- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Thanks very much. Your website is extremely helpful, too--I'm sure
I'll be referring to it often.

I appreciate the help!
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find+Replace Dialog Box, Replace with Format problem Kathy Microsoft Word Help 3 February 1st 08 04:26 AM
Find multiple characters in one find using MSword find/replace Cliff Microsoft Word Help 2 October 29th 06 07:48 PM
Replace fonts between quotes from regular text to bold? mdlayton Microsoft Word Help 2 May 17th 06 10:41 PM
Using find and replace or macros to replace page ranges JeremyC Microsoft Word Help 7 February 13th 06 09:20 PM
Find/ Replace is auto-capping the words I want to replace with Graham Mayor Microsoft Word Help 8 January 27th 06 01:39 AM


All times are GMT +1. The time now is 09:14 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"