#1
|
|||
|
|||
Word Regular Expressions: zero or more occurences?
C
C1 C2 CA Code:
[A-Z]{1}[0-9]{0,1} [A-Z]{1}[0-9]* [A-Z]{1}[0-9]? Is there anything wrong with the use of * and ? It seems that {0,1} is a wrong use. |
#2
|
||||
|
||||
If you consider what '0 or more occurrences' means, in the context of looking for [A-Z]{1} followed by '0 or more occurrences' of [0-9], that's really no different than looking for [A-Z]*; after all, '0 or more occurrences' means you don't really care whether there are any of [0-9] after [A-Z].
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Maybe I should have put it more clearly.
I want to find C C1 C2 but not CA If Find What: [A-Z]* it returns C, C1, C2 and CA (which is not wanted). |
#4
|
||||
|
||||
Try:
<[A-Z][!A-Za-z.,\!:;^13]{1,} Note that the 'C' match per your example will include the following space, if there is one, but it won't match 'C' followed by any of !:;^13.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Quote:
http://word.mvps.org/faqs/general/usingwildcards.htm It states that zero or more occurences is rejected by Word as incorrect syntax and thus not available in Word Find & Replace. And, Your codes cannot find "C". |
#6
|
||||
|
||||
I did say it would find 'C ' (it will also find 'C.' and 'C,'), but not 'C!', 'C:' 'C;' or 'C^13'. A document cannot have 'C' (i.e. C with nothing after it)...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Yes, I got it. Thanks.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
regular expressions in footnotes | loes | Word | 3 | 09-04-2019 07:52 AM |
Regular expressions for text with complex formatting | Kreol2013 | Word VBA | 1 | 04-12-2013 07:33 PM |
regular expressions for empty lines | eNGiNe | Word | 1 | 01-21-2013 06:38 AM |
Regular Expressions: [!0-9] does not work??? | tinfanide | Excel Programming | 4 | 05-30-2012 04:09 AM |
Issue skipping characters by Regular Expressions in Word | pochtara | Word VBA | 0 | 04-01-2010 05:37 AM |