0

I would like to find and replace as below using wild card. More particularly, I would like to find any character of one or two digits of the following patterns in MS word and get rid of the strange characters before and after the real characters.

< 1 >      -> 1
< 10 >     -> 10
< c >      -> c
< + >      -> +
< ++ >     -> ++

I tried by the following formula using wildcard pattern, but it only works with numbers of one or two digits. How can I do this with all other characters of one or two digits?

Find:     < ([0-9]{1,2}) > 
Replace:  \1 
2
  • [0-9] is a range in a set of characters. You can add other ranges like 'a-z', 'A-Z', or other characters you want to match. In your case, try [0-9a-z+]
    – ischeriad
    Jul 11, 2018 at 10:48
  • Thank you. It may help. But it is just a sample, and I would like to include all characters not limited to the presented characters above.
    – Steven J
    Jul 14, 2018 at 1:41

1 Answer 1

1
Find:     < ([! ]{1,2}) >
Replace:  \1

Explanation:

[! ] any character that's not a space. Because your wanted string is separated by a space from the following, unwanted string.

{1,2} at least one, maximum of two occurrences thereof

Note: In Word 2003, I had to use {1;2} as a quantifier.


Remarks:

  • if you want to be more general, you can use [! ]* to match any number (zero or more) of characters.
  • &lt;and &gt; are not strange characters but HTML entities for < (less than) and > (greater than).
  • you might want to learn about Regular Expressions in general.
  • ! is different from ^, which is more commonly used in regular expressions to negate a character set. I used this page, section Wildcard characters you can use, to learn about this.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.