merch89 merch89 - 1 month ago 6
Javascript Question

Matching varients and mis-spellings of a word using RegEx in MS Word

I am trying to capture varients of a word using Microsft Word find and replace function. Here is a searchable snippet:

There are going to be 3 instances of the word successful for the purpose of Regex matching. Here is the second sucesfull and here is another succesfull , both spelt incorrectly.


This is my Regex expression used in Find and Replace with "Use Wildcards" selected (I have also tried this with replacing the braces with brackets with no joy)

<([Ss]uc[1,]es[1,]ful[1,])>

Answer
[Ss]uc{1,}es{1,}ful{1,}

Replace the [ ] with { } and it should work fine. The curly braces specify how many times you want a character to repeat. Square brackets are used to specify the acceptable characters.

So the current regular expression will match the following.

  • succcccesssfulll
  • sucesful
  • successful
  • Successsssfull

and so on.

I think this is cleaner and easier to type.

[Ss]uc+es+ful+

"+" counts for one or more occurrence of a character.

Comments