Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find+Replace Dialog Box, Replace with Format problem | Microsoft Word Help | |||
Find multiple characters in one find using MSword find/replace | Microsoft Word Help | |||
Replace fonts between quotes from regular text to bold? | Microsoft Word Help | |||
Using find and replace or macros to replace page ranges | Microsoft Word Help | |||
Find/ Replace is auto-capping the words I want to replace with | Microsoft Word Help |