Word: Replace and reformat text inside square brackets using wildcards

June 20, 2011

My husband wanted to select a long column of text and find any text that was inside square brackets and reformat it so that the text — and the square brackets — was 4 pt and blue (no, I don’t know why either…).

This is an ideal job for using wildcards in Word’s find and replace. However, square brackets are special characters in wildcard searches, so they have to be treated differently. With some help from http://word.mvps.org/faqs/general/usingwildcards.htm and a bit of trial and error, I figured it out. I explain what all the settings mean after these steps, if you’re interested. Meantime, here’s my solution, which works in all versions of Word:

  1. Select the text you want to change (e.g. entire document, selected paragraphs, selected columns or rows of a table).
  2. Press Ctrl+H to open the Find and Replace dialog box.
  3. Click the More button.
  4. Select the Use wildcards check box.
  5. Put your cursor into the Find what field.
  6. Type the following exactly (or copy it from here): (\[)(*)(\])
  7. Go to the Replace with field and type: \1\2\3
  8. Click the Format button, and select Font.
  9. On the Font dialog box change the settings to what you want — in my husband’s case, this was 4 pt and blue — then click OK. Your Find and Replace dialog box should now look like this:

    Find and reformat text inside square brackets

    Find and reformat text inside square brackets

  10. Click Replace All.
  11. Once all replacements have been made, check that you got what you expected before making further changes to the document. If it’s all OK, save your document with the new changes.

What it all means

The three elements of the Find are:

  1. (\[) — You need to find a specific character (the opening square bracket), so you need to enclose it in parentheses. However, because the square brackets are special wildcard characters in their own right, you need to tell Word to treat them as normal text characters and not as special characters, so you put in a backslash ‘\‘ (also known as an ‘escape’ character) before the [.
  2. (*) — This tells Word to look for any characters after the opening square bracket. There’s no limit on what sort of characters (alpha, numeric, or symbols) Word is to find, or on how many there are.
  3. (\]) — This tells Word to stop the find at the first closing square bracket it finds after an opening square bracket followed by any other characters. As with the opening square bracket (1. above), the closing square bracket is a special wildcard character, so needs a backslash in front of it for Word to treat it as ordinary text, and it needs to be enclosed in parentheses as it’s an exact match you want.

There are no spaces between any of these elements — the aim is to find a string such as [green frog] and replace it with exactly the same text but formatted in a different color and with a difference font size.

The three elements of the Replace are:

  1. \1 — Tells Word to replace the first element of the Find with what was in the Find (the opening square bracket).
  2. \2 — Tells Word to replace the second element of the Find with the same text as what was found. In other words, keep the exact text as was found, but change it’s font size and color.
  3. \3 — Tells Word to replace the third element of the Find with what was in the Find (the closing square bracket).

As with the Find elements, there are no spaces between these elements. You still want [green frog], not [ green frog ].

See also:

[Links last checked June 2011]


  1. I’m very sorry, but the wildcard searchstring “(\[)(*)(\])” isn’t valid in Word 2007. It should be “\((*)\)”, so no brackets around “\(” and “\)”.


    The Netherlands

  2. Same here – doesn’t work in Word 2003 either. For some reason no matter what I do, it won’t find the square bracket character.

  3. Hi KT

    I just tested it again in Word 2003 and it worked fine for me. I didn’t try to type the find or replace strings — I just copied them from steps 6 and 7 on this page and pasted them into their respective fields on the Find and Replace dialog box.

    Make sure you have ‘Use wildcards’ checked too (Step 4) otherwise it won’t work.


  4. Hi KT

    One other thing… Make sure that when you select the font color etc. for the replace action, that your cursor is in the ‘Replace with’ field. In my testing just now, I inadvertently left it in the ‘Find what’ field and of course, no replacements could be made as there was nothing in the document with the font/size I wanted!

    An easy error to make as I think Word wants to apply the font formatting to the ‘Find what’ field by default and you have to explicitly put your cursor in the ‘Replace with’ field to make it happen.


  5. Hi Wim

    I just tested my original solution in Word 2007 and it worked fine. See possible reasons for it not to work in my answer to KT (above).


  6. I tried the search string again and now it worked!

    I guess I was a little bit too quick in my response.

    Sorry about that!

    FYI: Here’s another way to get the same result: \[(*)\] and replace with [\1].

  7. It Worked!! Actually both of these worked:

    Find: (\[)*(\])
    Replace: ^& (means replace with contents that was Found


    Find: \[(*)\]
    Replace: [\1]

    I actually think (since I’m sure I tried the first one before I posted the first time (I tried EVERYTHING!) that I may have put the “formatting” on the Find instead of the Replace as Rhonda said. :-\ Can’t think of why else it wouldn’t have worked.

    Oh well. :-D I’m all set now! Thank goodness and thanks for all your help!!

  8. Hello, Thanks you for such a useful page.
    I am trying to clean up the text from an old book which I got from the Gutenberg Project. It has hundreds of sets of square brackets containing numbers, which are there for references. I wanted to delete them, but couldn’t figure out how to do this.
    I simply cut the symbols from line 6 of your tutorial and replaced each set of brackets containing numerals with nothing. It worked wonderfully.
    Thanks once again.
    Regards from Australia.

  9. Thank you!! Worked like a charm for me in Word 2003. I was trying to globally style a variety of words found within and just replaced the [ ] above with .

  10. Not sure what happened to my comment above, but the less-than and more-than brackets in my note disappeared. They were the characters I had to search for:

  11. Hi Faith

    I don’t know what happened to your ‘arrow’ brackets, but two possibilities spring to mind — did you check the Use Wildcards box, and did you enclose what you were looking for in round brackets?


  12. You can even Find & Replace Multiple Words in Multiple Word files using simple software.


  13. Rock on! thank you so much!

  14. Works fine in 2007 thank you. You just need to select “use wildcards” and away you go. Worked as you said so thank you!

  15. This worked well for me in Word 2007. I have uncovered a strange glitch though. I’m using this as a work around to help Excel maintain source formating when using data for a print merge. Since excel won’t keep the original formatting I am using this to put brackets around blank records adding a red font and changing the characters to hidden on unfinished data. This allows meto print the work in progress without the holes from all the unfinished data. The problem is that word puts a section break in between the brackets which signal a new page so there are empty spaces were the unfinished cells are. If I change the section break to continuous then I lose the data merged into my header. Is there something about the formula that I can change so it won’t do this?

  16. Hi Diane

    I’ve never tried what you’re doing, so I’m not sure what’s going wrong. A section break in Word is indicated by ^b in the Replace field — do you have one of those in there?


  17. No ^b in the Replace field. I figured out that when word completed the print merge it would place a section break at the end of each page. I’m not exactly sure why. But I did a search and removed all section breaks after the merge was completed and now your formula works brilliantly.

    This really is a terrific work around for highlighting blank cells when doing a print merge. Thanks for your post and for saving me hours and hours of time. Amazing formula!

  18. So helpful, thanks!

  19. Thank you!! This was very helpful and saved me quite a bit of time.

  20. Thank you! This is saving me a LOT of work!

  21. It’s working fine! Thanks a lot for the tip that’s saving me a lot of time…

  22. How do I get Word to find parenthesis containing numbers in between and delete the whole string?

    For example, a sentence may look like this:
    “ACME Company (1.10); XYZ Company”

    Desired outcome:
    “ACME Company; XYZ Company”

  23. There might be an easier way, but this one worked for me using your example:

    Find what: ( )([\(])([0-9]{1,2})(.)([0-9]{1,2})([\)])
    And Replace with nothing.

    NOTE: In the Find What phrase, you’re looking for a space ( ), followed by an opening parenthesis ([\(]), followed by a one- or two-digit number ([0-9]{1,2}), followed by a period (.), followed by another one- or two-digit number ([0-9]{1,2}), followed by a closing parenthesis ([\)]).

    If you want to make sure that you ONLY remove the numbers associated with ACME Company and not anything that matches this pattern, add ACME in front of the Find What string: (ACME Company)( )([\(])([0-9]{1,2})(.)([0-9]{1,2})([\)]) and then put \1 in the Replace With field.

  24. Thanks! It missed a few numbers that didn’t have a number in front of the decimal like (.10) and (.1) which I just had to tweak to ( )([\(])(.)([0-9]{1,2})([\)])and run again. Thanks again! This saved a lot of clean up time!

  25. Is there a way to find and delete all text that is not enclosed in parenthesis?

  26. I did this and it worked – but what do you put in there so the brackets remain as they were (I do not want to change the brackets themselves, just the text within the brackets)? The end result should be red text within black brackets. Any way to do that?

  27. Hi Pat

    I’m not sure that you can automatically. That said, I’m a beginner at wild card searching, so perhaps there’s a way. However, if you use that ‘Find’ string above and DO NOT replace, you can find each instance and then manually change it to red text between the brackets.

    And once you’ve changed it to red, do another ‘find’ for the next one, and this time select the text you want to be red then press F4 (which applies the last action — i.e. applies the same colour you applied to the first one). NOTE: If you do any other action — like delete something — then F4 will delete, and you’ll have to undo and manually apply the red again.

    One way to avoid F4 doing weird things is to select the red text, press Ctrl+Shift+C (this copies the formatting), then on the next ‘find’ select that text, then press Ctrl+Shift+V (this pastes the copied formatting to the selected text).


  28. Hi again Pat

    One other way to do this… follow the instructions in the blog post for changing the whole string to blue (but in your case, choose red). Then run two more wild card find/replace passes to change the colour of the brackets back to normal.

    In the first pass, just put (\[) in the ‘find’, and \1 in the ‘replace’ field. While in the ‘replace’ field, click No Formatting to remove the blue from the first run, then click Format > Font and choose Automatic as the font colour. Make sure ‘Use wildcards’ is selected. Click Replace. If it does what you want, then click Replace All.

    In the second pass, you do the same as the first, except you put (\]) in the ‘find’. Everything else stays the same as for the first pass.


  29. What is the command if I want to replace any word before the special character :
    for example “Andy: blablablabla” I want replace Andy: and patterns that is the same but I dont want to replace 10: (I want to replace only letters and not digits.) Please help me out, this will be a great help to me. Thank you !!!

  30. Hi Winfrey

    I’d try this as a wildcard find/replace:
    Find: ([A-z]@)(:)
    Replace: whatever you want to replace it with – leave blank if you want to replace with nothing. If you want to keep the ‘:’, then replace with whatever you want to replace it with plus \2

    The [A-z] bit finds any letter (upper or lower case) and the @ finds any number of letters.

    If you don’t want the option to preserve the colons, then find: ([A-z]@:)


  31. Thank you so much Rhonda! This really helped me a lot!

  32. really interesting post. i need a wildcard that would help me change a text that appear in track changes (from a specific reviewer) to appear in tc and yellow highlight – is it possible? thanks for your help

  33. Hi Karolina

    I would have no idea where to start with that, though I suspect you might need to write a macro to do it. Try asking this question on the Microsoft Word forum: http://answers.microsoft.com/en-us/office/forum/word


  34. This just worked perfectly in word 2013. Thank you so much!

  35. I can not say how much appreciate you. you taught me a big trick to manage documents in word. thank one million times! :)

  36. Thank you!!! Worked like a charm in Word 2010. Saved me HOURS of work.

  37. Hello. Is there any way I can get this exact functionality within Excel 2013? I have used it successfully in Word 2013 (thanks to this helpful article), but Excel seems to take my “replace” text as a literal string and will not parse my expression properly.

    I have several cells that contain [1], [2], [3] and so on. I want to format the text inside each cell to be a specific font, size, weight and color.

    For example:

    Cell one: [1]
    Cell two: [2]
    Cell three: [3]

    In Word I use the replace functionality to find this: (\[)(*)(\]) and then replace it with this: \1\2\3 and with special font formatting. This works well.

    In Excel I use the replace functionality to find this: ~* and then replace it with this: \1\2\3 and with special font formatting. This does not work. Instead, each cell ends up looking like this:

    Cell one: \1\2\3
    Cell two: \1\2\3
    Cell three: \1\2\3

    Excel is parsing the “replace” expression as a literal string. I’ve tried different ways of trying to get the desired result, but keep coming up short.

    I did some research and everything I find points to Word being able to use expressions like “\1\2\3” but nothing mentions Excel. Any advice?

    Thank you kindly.

  38. I don’t know that this will work with Excel. Excel was designed for numbers and isn’t really a text editor, so I expect that your results are typical of what you can/can’t do in Excel. I know that you can’t do things in Outlook or PowerPoint that you can do easily in Word, and both of those are more text oriented than Excel.

  39. This is great, However, I’m struggling to tweak the code to help me find and remove many iterations of this type of time stamp [00:00:53:00]. Obviously the numbers would continue to change. Your help would be great if you can. Thanks

  40. thank you. best regards and a happy new year.
    Corneliu, Romania.

  41. Hi Andy

    Use wildcards, and put this in the Find field:

    Put nothing in the Replace field, Replace All, and you should remove them all.

    If you used the square brackets, then you can do a standard Find/Replace for [] to remove those too.


  42. thank you, this was very helpful

  43. THANK YOU! These instructions saved me hours of work.

  44. I have been looking for these instructions everywhere — thanks so much for saving me more frustration!

  45. Thank you so much for this solution as I was literally going to have to spend days removing numbers inside square brackets inside a massive word document and now with your solution something that would have taken me days was done in seconds. I love you!!!!!!

  46. Hi

    Looks like, between you, you know lots about ‘find and replace’ and wildcards!

    I’m working on proofreading several hundred documents, most of which need a couple of repetitive changes made to the format of numbered lists, but as I’m new to wildcards, I can’t work out what I need to enter to achieve what I want.

    Issue 1: the current format is like this:

    1) …

    2) …

    etc, and I need it to be:

    (1) …

    (2) …

    Issue 2: the current format is this:

    (1) …

    (2) …

    etc, and I need it to be:

    1. …

    2. …

    If you can help me out on this, I would be very grateful: it would cut down the time I spend on each document considerably.

    Best wishes

  47. Hi Michael

    If the authors have used auto numbering, as I suspect they may have because it’s easy, then find and replace — whether with wildcards or not — won’t help you much.

    Advice: Make a copy of one of your documents BEFORE you do the process below. That way you don’t mess up your original until you have figured out what to do and dealt with the ‘gotchas’, and decided whether you REALLY want to do this…

    Your best bet is to select a range of numbered items, then click the drop-down arrow to the immediate right of the 123 icon on the Home tab, then select the format you need. If you need a format other than that listed, select ‘Define New Number Format’ and add/delete parentheses around the number.

    Be aware that you could totally mess up the numbering sequences!! And may have to start each new set of numbers at ‘1’ again…. The auto numbering in Word may not behave as you want it to. At which point you’ll ask yourself WHY you want to change the punctuation surrounding the numbers and decide it’s just not worth it.

    If it doesn’t change meaning, do you REALLY need to spend time and energy (and frustration) on this?


  48. Hi Rhonda

    Thank you for taking the time to reply to my question so thoughtfully.

    In response, no, the authors haven’t used auto numbering (and, for the reason you’ve suggested, I don’t want to mess up the formatting of the document, which will end up in SGML on the web; and the reason I’m having to make the tedious changes is so that the documents end up conforming to the house style. (The way I look at it is that if they’re paying me for it, I’ll do it!)


  49. Hi Michael

    If they’re paying you for it, AND if the numbers have been manually entered, then yes, there should be a way to use F&R (with or without wildcards) to do what you want.

    Leave it with me for a bit and I’ll get back to you… hopefully with a solution that only targets the numbers and not anything else with that punctuation.


  50. Hi again Michael — can you tell me what comes after a number/punctuation combination? one or more spaces, or a tab?

  51. Hi Rhonda, it’s a space

  52. […] another post on this blog, Michael commented that he had a situation where he needed to run find and replace routines […]

  53. Hi again Michael

    As your requirements vary quite a bit from the original post, I’ve written new instructions for you. They’re here: https://cybertext.wordpress.com/2015/07/14/word-wildcard-find-and-replace-for-numbers-and-trailing-punctuation/


  54. Wow – that’s amazing. A whole page dedicated to my question! Thank you Rhonda. I will try this out on the next document and report back to you. :-)

  55. one question before I go ahead, Rhonda: if the list uses letters, rather than numerals, thus:

    a) …

    b) …

    and I want:

    (a) …

    (b) …

    how should I tweak the find and replace strings?

  56. Hi Michael

    I’ve updated that new post with the tweaks for letters.


  57. Hi Rhonda

    Thanks again for your time, and for updating the blog with the tweak for letters. I tried the string, and in the main it works. However, it’s inserting a line space before the entry (this can be seen when it highlights what it’s about to change), so pushing everything down by a line when it does the replacement. What, in the find string, might be doing this, do you think?

  58. Hi Michael

    It FINDS a paragraph marker above the entry (that’s the (^013) part), and then replaces that paragraph mark with itself. In my testing it didn’t add anything more than what was already there. I’ve emailed you privately.


  59. Thank you for the excellent instructions – it was exactly what I was looking for!

  60. Very useful! This shortcut saved me so much time in formatting old plays from Project Gutenberg. I can’t thank you enough.

  61. Hello,

    I am having a hard time getting the steps to work. I am trying to make changes within the entire word document. When I follow the steps it changes the font of the whole document instead of the font within the brackets. The content within the brackets is [w/p G-5]. I am using Word 2010.

  62. Hi Zan

    Try this (with wildcards ON of course):
    Find: (\[w/p G-5\])
    Replace with: \1 (and specify the font colour, size etc. for the Replace With)

    Test by using use ‘Find Next’ and ‘Replace’ until you are certain you’re not changing anything else. Only use ‘Replace All’ once you are confident of not messing anything else up.


  63. Thank you very much!

  64. Is there a replace command that can delete the entire sentence with a “specific” word “INSIDE” the sentence, not just at the beginning nor end of the sentence? ie..
    yadi yadi ya DIR yadi yadi ya.
    ^13*:*|*:*^13 Does not work for me.
    From my understanding, the following are the descriptions of the codes used:
    ^13 = paragraph tab
    *:* = any and all characters
    | = sentence selection
    = the word “inside” the sentence that is searched for … DIR

    So, the command should execute a search and select the beginning paragraph tab in a sentence with the word DIR inside it and then continue to select the rest of the sentence up to the next paragraph tab. At this point I can leave my “replace with” empty and click select all to perform on the entire document.

  65. Hi Stuart

    I’m not sure where you got your list of expressions from, but I don’t think *:* and | are used in Microsoft Word. These articles describe what expressions ARE used in Word: http://word.mvps.org/faqs/general/usingwildcards.htm and http://www.gmayor.com/replace_using_wildcards.htm

    Now to your question… I got this to work, but only partially. You would have to check each item found because it may get some you didn’t want, and miss others.

    One that worked was:


    but this gets more than a single sentence where DIR occurs. Note that I’ve included the main punctuation marks that typically end a sentence.

    Another that worked more precisely was

    (. )(*)(DIR)(*)([.:;\!\?\)\(])

    as it selected just a sentence containing DIR and the preceding period and space (there’s a space after the period in the Find string). You would have to add a period in the Replace to replace the one found.

    Although (^13)(*)(DIR)(*)(^13) worked too, you would have to ensure that every sentence where DIR occurred was in its own paragraph.

    These may help, but won’t cover every situation. Perhaps run some of these first, then do a final Find for any DIR outliers.

  66. This stuff works perfectly on Word 2016. Thank you! Five Years later, and this post still applies. You rock!

  67. I am a beginner when it comes this stuff. What I am trying to accomplish is a mass replace/delete on a document that is approximately 1,700 pages in length. In all occurrences each section starts with: Correct Answer: and ends with QUESTION nnn. I have tried a large number of the suggestions above but keep ending up with a completely gabled document.

  68. Assuming you want to delete everything between ‘Correct Answer:’ and ‘Question’, this should work:
    * Wildcard find/replace
    * Find what: (Correct Answer:)(*)(Question)
    * Replace with: \1^013\3
    (Note: the ^013 between the \1 and \3 is a paragraph mark)

    PLEASE work on a COPY of your document first.

  69. I need to delete a ton of brackets within a document. How can I do that?

  70. Hi Stephanie

    The easiest way to do that would be a standard Find/Replace with the opening bracket as your first Find (Replace with nothing) followed by Replace All, and the closing bracket as your next Find (again, Replace with nothing and do Replace All). I think that would be quicker and easier than figuring out a wildcard routine for it.

    However, be aware that removing brackets may well change the meaning of the content, so I’d only do ‘Replace’ not ‘Replace All’ and check each instance to see if the brackets needed to be replaced with something else, such as an en or em dash.


  71. Hi guys i wanted to Replace and reformat text inside round bracket () instead of square brackets [] using wildcards. Any idea how can it be done?

    I tried using this (\()(*)(\)) but failed.
    Thanks in advance


  72. Hi Joe

    You need to enclose the special characters in square brackets, so ([\(])(*)([\)]).


  73. Hello,
    I can’t print text within the brackets even though I can see them on the screen in Adobe, please help.
    Thank you in advance.

  74. Rhonda, congratulations for your excellent support to this page.
    I guess, it’s a very useful resource for many of us needing that kind of help using Word Search & Replace.

    My question, if you still there, or any other user who knows the solution, is how to find and replace bulleted and numbered list formatting.
    My work here needs just delete them at once.
    There is no such thing at “Format” nor “Special” button, but only Section, Fields,…

    I have a very big text with too many bulleted lists with no character in it, among normal text.


  75. Hi Gab

    The easiest way to do this is to select all text with the style, then clear the formatting. If you used the bullet icon from the menu to apply the bulletting, then the style is ‘List Paragraph’; if you have your own style for bulletting, then you need to know that style’s name. The steps below assume ‘List Paragraph’ is the style.

    1. On the Home tab, go to the Styles group.
    2. Click the tiny arrow in the right corner of that group — this opens the Styles panel.
    3. Hover over the ‘List Paragraph’ style’s name until you see the drop-down arrow for it.
    4. Click that arrow.
    5. Click the ‘Select All xx Instances’ option.
    6. Back on the Styles panel, go to the top and click ‘Clear All’ — this takes the formatting of the style back to ‘Normal’.

  76. Rhonda, thank you very much for your prompt response!

    Unfortunately, bulleted text is already under Normal Style and, thus, it’s masked/hidden among normal text…
    I see no way to isolate it. :-(

    I’ll ask a favor to send a tiny piece of it to your e-mail, just 3 pages of more than 200 of original one.

  77. I spent over an hour trying to find a way I can remove links enclosed in curly brackets from a document. (\{)(*)(\}) is the only thing that worked. THANK YOU!

  78. Perfect!! Thank you :)

  79. How to find anything text using of wildcards Please tell me about the string or regex. ex: we have number references and in all reference text are normal (no italic or no bold) so i want to change formatting .Suppose journal title s/b in italic or also book title s/b in italic format. word 2007 or 2010 version will used.

  80. Hi Rhonda,

    I REALLY hope you get to see this because I could really use your help. Is there a way to highlight only the contents WITHIN the brackets. I tried your suggestion above but unfortunately it highlights the [ ] as well, I only need to apply the changes to the contents in the [ ]. I’ve done this before but forgot what I used. I have tried asking on a lot of forums and have not found a solution to this.

    Kind regards,

  81. Hi Hatta

    I got this to work, but only after doing three find and replace passes:

    1. On the Home tab, select a highlight colour (this is important!), then follow the steps above until Step 8. At Step 8, select Highlight. Run the find/replace. This will highlight the entire string, including the square brackets. (NOTE: If you don’t select a highlight colour before you start, no highlighting will be applied.)
    2. On the home tab, select No color as the highlight colour (important!!). If it’s not already open, open the Find and Replace dialog, make sure Use Wildcards is turned on, then leave just (\[) in the Find What field. In the Replace field, you only need \1. Then click the No Formatting button at the bottom of the Find and Replace dialog – there should be no formatting info below the Replace With field. Run the find/replace – this will clear the highlighting from the opening square bracket.
    3. Repeat step 2 above, changing [ to ] in the Find What field.


  82. Rhonda, I think there is no need to highlight or three passes way to go.
    If she wants to replace only within brackets, I suggest this:
    Find: \[(*)\]
    Replace: [New text here]

    \[ finds the 1st bracket
    (*) finds the content
    \] finds the 2nd bracket
    [ replace 1st bracket
    ] replace 2nd bracket

    Here I could reproduce exactly what I understood she wants to do.
    Tell me if I’m in mistake.

  83. Hi,

    I apologize if I confused you. I did not want to highlight the contents in the brackets, what I meant was, select all the contents in it. I have a 300 pages doc that containts hundreds of [sample], what I need to do is make all the words within the brackets to italic. So I need to go from [sample] to [sampleitalic] (sorry I don’t know how to make it italic here). When I tried your formula above, it included the bracket when I hit find, so that means it’ll change the brackets to italics too, I need it to stay normal. Am I making sense?

    I am so sorry for my bad english.

  84. This case, you’ll need 3 passes, as Rhonda described above.
    No need to highlight too.

    1 – Find: \[(*)\]
    Replace: (Blank field)
    (Italic formating)
    (All selected will be italic)

    2 – Find: [
    (Italic formating)
    Replace: (Blank field)
    (No Formating -> Regular Font)
    3 – Find: ]
    (Italic formating)
    Replace: (Blank field)
    (No Formating -> Regular Font)

  85. I forgot to say: passes 2 and 3, untick Wildcards checkbox.

  86. Thanks, Gab!

    That did the trick. Thank you for saving me hours and hours of reformatting!

  87. Hi Rhonda.

    I’m trying to replace multiple occurrences of timestamps in the format [00:00:00] “which, obviously, changes at each instance of the timestamp) with the format [00:00] keeping the last five digits intact from the original. Is there any way to do this with find and replace?

    Thanks in advance!

  88. Hi Emily

    Try this (wildcards turned on):
    Find: (\[[0-9][0-9]:)(*)


  89. Hi, Emily.

    Try this:
    Find: (\[)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(\])
    Replace: \1\4\5\6\7

    And you’ll get 4 last digits, trimming the 2 first.
    Replace field is the number of ‘()’.
    Here it worked.

  90. Hi, Rhonda!

    Your solution is far more elegant and graceful!

  91. Rhonda and Gab,

    Thank you so much! Tested and they both worked. Gab’s solution was a better fit for me because I had manually altered some of the timestamps and those were left intact. Rhonda’s solution worked but still stripped the last bit from the altered timestamps so I was left with [00] instead of [00:00]. Will just have to remember to make sure all formats are the same when I use it in the future. Thanks again to you both!

    One last – what if I had a string of text before the timestamp that I wanted to be left intact, would replace be able to work? e.g. [inaudible 00:00:00] to [inaudible 00:00]

  92. Hi Emily

    Modifying Gab’s solution, try:
    Find: (\[inaudible )([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(\])
    Replace: \1\4\5\6\7


  93. Thanks so much Rhonda! That works for me!

  94. Hi! I want to format with a style the capitalized words between a paragraph mark and the first “,” in a Word document. By using the several methods outlined here, I can’t avoid the paragraph mark and the comma being formatted as well. Can I do it with find/replace in one pass (it’s a 500 page document with 12,000 pragraphs!)?


  95. Hi Jorge

    I’m not clear on what you want to do.

    Do you want the first words of EVERY paragraph up to the first comma capitalised? For example:
    * para 1 – HOWEVER, the xxxx
    * para 2 – SHE PURCHASED APPLES, oranges, and pears

    Or do you want to find the first capped words in a paragraph, up to the first comma, and format them in some way (e.g. italics, bold)? For example:
    * para 1 – They arranged for the TRUCK to pick up the furniture, rugs, and lamps. (where TRUCK would remained capped and in italics [or other styling])
    * para 2 – In Step 3, SELECT the option, then click OK. (where SELECT would remain capped and in italics [or other styling])

    Or something else?


  96. Sorry if I was unclear. Just imagine these three paragraphs:

    ARTHAUD, Jean; 6/5/1773, Toulouse (Haute-Garonne); capitaine, 70 Régiment d’Infanterie de Ligne; blessé le 3/4/1811 (deux coups de feu), Sabugal (Portugal)
    Source: SHD/GR 2Yb 367

    ARTREUX, Juste; 1/4/1774, Lyon (Rhône); lieutenant, 34 Régiment d’Infanterie de Ligne; tué le 19/9/1812, siège de Burgos (Castilla y León)
    Source: SHD/GR 2Yb 236

    — ; capitaine, 5 Régiment d’Infanterie Lé-gère; blessé le 28/10/1812 (coup de feu à la cuisse gauche), Sagunto (Valencia)

    I want to have ARTHAUD and ARTREUX (always caps but sometimes more than one word, and always at the beginning and before a comma) to have a different style from the rest of the paragraphs. What I find is that with Find/Replace (^13)([A-Z])(*,) the paragraph marks AND the comma also get the new style, so when I use StyleRef in the header, the comma appears and when there is no capitalized name (see 3rd para above), a blank space appears.

    To summarize: how to change style BETWEEN a paragraph mark and a comma, without affecting either of these characters?

    Thanks again,


  97. Ah! Someone else may have a clever idea on doing this in one pass, but the only thing I can come up with at the moment is a solution that involves a couple of passes.

    First pass is your initial wildcard find/replace string (in my testing I applied the ‘Intense Emphasis’ character style, but obviously you’d apply your special style).

    Second pass is to find the paragraph marks with that new style and change them back to the underlying paragraph style — Find: (^13) [with the applied style name also selected]; Replace: \1 [with the ‘Default paragraph font’ style selected].

    Third pass is to do the same, but for the commas — Find: (,) [with the applied style name also selected]; Replace: \1 [with the ‘Default paragraph font’ style selected].

    NOTE: I couldn’t get your find/replace string to work with a hyphenated capped name (e.g. SMITH-JONES, Sam), so you might have to find those separately, if you have any.

  98. Thanks Rhonda. I would have guessed there was a direct way to do something as simple as Find/Replace a text string BETWEEN two characters without VBA, but it seems the only way is a two or three step procedure. None of the pay addins offer this either. Thanks for the hyphenated cap tip, will use [!,] instead.


  99. Hello, this is wonderful, but I have run into a glitch. When I hit Replace All, I get an error message that says : The Replace with Text contains a group number which is out of range. I am not sure what this means, but I cut and pasted the \1\2\3 from your instructions.

    I hope I can get this to work. I am editing music, and need to change all of the chords from black to red.

  100. Ok, I entered everything again and it seemed to accept it. I was really excited, but I found it turned EVERYTHING blue, not just the parts inside the brackets.

    I am still hopeful

  101. Hi Priscilla

    Can you post exactly what you are trying to change, and what you want it to be? The info in the main post obviously relates to a specific scenario — changing text inside square brackets (including the square brackets) to blue.


  102. Thank you for responding so quickly. (I made an error when I said that it changed everything to Blue… It should have been red)

    Here is what I am trying to do. I need the part inside the brackets to be red.

    Forse [C] questo ti sembrerà un [G] strano
    Ma la [F] ragione ti ha un po’ preso la [C] mano
    Ed ora [Am] quasi con[E7]vinto [F]che
    Non può [C] esistere un’[G]isola che non [C] c’è [F] [C]


  103. Hi Priscilla/Dee

    This is similar to the issue that Jorge had the other day (see comments above yours. And the solution is similar too — you’ll need to do three passes.

    First pass:
    * Wildcards ON
    * Find what: (\[)(*)(\])
    * Replace with: \1\2\3
    * Format: Font > Red (ONLY do this with the cursor in the Replace with field)
    * Run the replace

    Second pass:
    * Wildcards OFF
    * Find what: [
    * With cursor in Find what field, Format > Font > Red
    * Replace with: [
    * With cursor in Replace with field: Format > Style > Default Paragraph Font
    * Run the replace

    Second pass:
    * Wildcards OFF
    * Find what: ]
    * With cursor in Find what field, Format > Font > Red
    * Replace with: ]
    * With cursor in Replace with field: Format > Style > Default Paragraph Font
    * Run the replace

    I don’t know of a way to avoid three passes, but they should be quick.


  104. Thank you… off I go

  105. Hi Rhonda,

    Thank you so much for your help last time. That did the trick! I apologize for not writing back sooner.

    I have another question though, I tried to replicate the formula (if you call it that) but for defined terms, all of which are enclosed in ” “.

    So the formula is \”(*)\” but unfortunately it selects the quotations as well.
    “Define” – when I use the formula above via replace and apply a bold formatting on it, it includes the ” “, is it possible to only have the contents between ” ” in bold and leave the ” ” as is?

    I hope I am making sense.

  106. Hi Hatta

    As for your other one, you’ll have to do this in three passes (two if you use straight quotes, not smart quotes). The second and third pass will find the bold quote marks and replace them with no formatting. See the comments immediately above for Priscilla’s issue and substitute ” for [ and ].


  107. My problem is that when I apply bold for the above… let’s say

    “Hatta” is defined as …

    It makes the entire line bold, from ” to …, everything is bold. Unlike in [ ], only the content inside and the [ ] is affected.

    I am really sorry if I am wording this poorly.

  108. Hi Hatta

    I got it to work, but you definitely get different results if you’re using straight quotes instead of smart quotes. For smart quotes, use (\“)(*)(\”) in the Find and \1\2\3 in the Replace (with bold) and it should work. If copy/paste from this comment doesn’t work, go to your original document and copy the opening quote mark from your document into the first part of the find and copy the closing quote mark into the last part of the Find.


  109. Hi.

    I’m facing a problem to select the rest of the line after NUMBERdotSPACE, like this:
    I need to select all lines commencing with number, dot and space.
    Number can be 1 or 2 digits.
    I tried:
    [0-9]{1,2}. *{1,}
    [0-9]{1,2}. (.+)
    [0-9]{1,2}. *@
    [0-9]{1,2}. ?{1,}
    I need to select all the line.
    I noticed that this syntax “[0-9]{1,2}. (.+)” works on other text editor that has Regular Expressions in Perl flavor. But won’t wok on Office Word 2010.

  110. Hi Personalize951

    Like you, I couldn’t get anything to work either. could only get as far as selecting the number, dot, space and first letter. There’s no indicator in Word of the end of a line (except where it’s also the end of a paragraph — either hard or soft line break), so I can’t see any pattern to this. Without a pattern, it’s almost impossible to get a ‘find’ happening.

    Can I ask why you’re trying to do this? Once you’ve selected the line, what do you then need to do with it? There may be another approach if I know what your purpose is.

    Also, consider asking your question on the Microsoft Word forums on Microsoft’s website — they have some very clever people who help others, and who may be able to help you.


  111. Rhonda, thank you very much for your kind and prompt response.

    In fact, I need to put all that lines in Bold to differ and highlight them from the others.

    It’s weird to have too many flavors of Regular Expressions.
    I had known about Office Word, Perl, Unix, UltraEdit, Notepad++ and others.
    Wonderful if we had just only one syntax.

  112. I’m considering to make changes using UltraEdit putting some special character to replace it with none when copying back to Word.
    But I’ll fall in the same problem: how to select ALL the line? Like you, I can get just numbers, dot, space and 1st letter of the next word…

  113. Rhonda, my dear, I have good news!!!

    Reading this:
    I found this:
    “This part of the expression matches the last names:
    ([! ]@)^13 ”

    So, I don’t want to exclude space, but I could exclude “&” for example.
    My Find string became like this:
    ([0-9]{1,2}.) ([!\&]@^13)
    Just that lines was selected.

    Problem solved!

    Thank you very much!

  114. Last comment: I am Gab Arito, but I could not login with this user this time, not know, wrong password, something.
    I’ve already been here at some post above.
    Thanks again.

  115. Hi Gab

    Congratulations on finding an answer and sharing it! The ^13 is code for an end of paragraph marker, so in my test, it selected the entire paragraph with the numbered item, not just the line it was on. I deliberately set some test items up to go over more than one line. But if that’s what you wanted, that’s great news.


  116. Hi, Rhonda.

    Problem solved. More informations about wildcards we got with this issue.
    Nice place you have here, where many people share its questions and we help each other.

  117. I am trying to replace lots of “/any text /” with (any text ) in Word 2010. While \/(*)\/ will find the text, (^&) as a replacement returns (/any text /), and using \(^&\) or \(*\) in the replace field both result in “group number out of range”. I thought I might be able to search and replace the (/any text /) but it is time consuming as I have to search for \(/ and replace it with something like & and \/\) with $ but these characters already exist in the document, so I am looking for a simpler solution? Why is the replace not working?

  118. Hi Don

    I went about it a different way. Using wildcards, try this:

    Find: (\/)(*)(\/)
    Replace: \2

    Do NOT do a Replace All until you’ve tested it on a copy of your document and are satisfied it doesn’t mess up something you didn’t expect.

    The difference between mine and yours is that I enclosed the escape characters and the slashes inside parentheses; this made them elements 1 and 3. You want to get rid of them, so the replace has just element 2 (the (*) part of the find being replaced with itself).


  119. My job involves finding such bracketed fill-in fields and turning them red to highlight them. This will be such a HUUUGE time-saver! Thank you so much!

  120. Hi, I give me solution for the following example,

    String : Password={my_pswd}123}

    I want to select the complete password key value “{my_pswd}123}” not “{my_pswd}”. Give me some suggestions..

    Thank You

  121. Hi everyone.

    I have a bit of a strange one. I’d post it in a separate thread as it has absolutely nothing to do with this one, but I couldn’t find where to post a new question and I couldn’t see a thread with a similar topic either. Sorry!

    I have a few documents – about 50 pages each. I need to insert some words around the center of each page. Is there any way to find the center of a page in Word? The document already has text and I’m not looking to align the text vertically, but I’d like to maybe insert something (a blank line, ideally, or text) into the center of each page so that I could either use find and replace on those blank lines or just manually go through the pages and find the blank lines. Anyone have an idea of how I might be able to do this? A macro would be great, but any other solution would be greatly appreciated. I’m using Word 2010 if that has any bearing.


  122. Hi Emily

    I don’t know of any way to do this, and I’m not clear on why you want to do this. If you want the reader to see this, you could perhaps use a watermark, but watermarks live in the headers, not on the main page itself.

    I’m also not sure that ‘centre on the page’ has a lot of meaning — printer drivers as well as page dimensions and layout mean that something like a blank line or a series of characters (e.g. QQQ) in the ‘centre’ can change position depending on those factors.


  123. Hi Rhonda.

    Thanks for getting back to me! Let me give more details. This is for a transcription project where I need to put in timestamps at the top and middle of each page. By “center of page,” I mean the center of the page as seen in print layout view in MS Word. I was hoping there may be some function to find the center of the page.

    I was thinking maybe a macro that maybe would utilize a line count or line numbers, find the median, insert a blank line which I could then easily find and timestamp. The only thing is I don’t want line numbers in the document, so if it was a macro, it would put in line numbers, find the median one, input a blank line there, remove line numbers. Gosh, this sounds complicated now that I’ve written it out! That’s just my theory of how this could be done and I don’t have enough VBA knowledge to construct a macro to do that, but any other suggestions of how this could be done would be great.

  124. Sorry, Emily. That’s got me beat, even with the extra info. I suggest you go to Microsoft’s forums, select the one for Word Programming and ask your question there.


  125. Thanks for giving it some thought anyway, Rhonda!

  126. Hi, Emily.

    Sorry to send as answer too many days after your question, but I was very busy at that time and could not give the proper attention.

    I’m not an expert in Visual Basic and I had to search to try to find a solution for your question.
    Also, the below solution may not be the best one and it could be improved.

    Try to upload this macro to your Word:

    Sub Loop_Insert()

    ‘ Loop_Insert Macro

    Dim i As Long
    Dim iLines As Integer
    Dim iPages As Integer
    Dim iMidle As Integer
    iPages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
    iLines = ActiveDocument.BuiltInDocumentProperties(wdPropertyLines)
    iMidle = Round(ActiveDocument.PageSetup.LinesPage / 2)
    For i = 1 To iPages + 1
    Selection.MoveDown Unit:=wdLine, Count:=iMidle
    Selection.EndKey Unit:=wdLine
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext
    Next i
    End Sub

    As you can see, it counts the number of lines per page and the number of pages of entire document.
    Then, it inserts a line at the midle of each page.
    After run it with some examples, I saw that the number of pages may increase after too many lines insert and may create blank pages at the end, depending of the document.

    But, if I understood well your task, to insert subtitles, I guess it will help in someway.

    If you want more help, feel free to ask.

  127. Thank you Gab Arito! No worries about the time – I’ve been looking for an answer for this on and off for about 4 months, so to me, this was very quick! :-)

    It does work, and as you indicated, on some documents it is adding a bunch of extra lines at the end, but I can work with that. Thank you so much!

    Best regards, Emily

    On Sat, Jul 28, 2018 at 10:11 PM, CyberText Newsletter wrote:

    > Gab Arito commented: “Hi, Emily. Sorry to send as answer too many days > after your question, but I was very busy at that time and could not give > the proper attention. I’m not an expert in Visual Basic and I had to search > to try to find a solution for your question. Also,” >

  128. Emily.

    Glad to know that it worked for you.

    If you want to decrease the extra pages at the end, make this little change:

    where you find
    For i = 1 To iPages + 1
    change to
    For i = 1 To iPages

    Doing that, the last page won’t be processed. But you will add, manually, the blank line at its center.

    Hope it helps.

  129. I have a Microsoft Word document with a lot of code like the following Question 1: [xDy-z.t-k] where x carries values ​​from [0-100]; y value from [0-100]; z is from [0-100]; t is from [0-100] and k is from [0-100]. I want to use the search and replace (Ctrl + H) function in Word 2016 to find the code that k = a certain value I want. Can you help me write the alternative characters to find the desired result. (use wildcards). Thank you

  130. Hi, blu.
    I guess that I could find a solution for your question.


    Where yyy is what you want to replace.

    I use Portuguese Regional setting on my Windows, so I need to put “;” inside braces.
    Some countries (Regional settings) uses “,” instead.
    Test and pick up what works for you.
    Perhaps, Rhonda has a easier way to do that.
    But it worked fine here on my Word 2010.

  131. I remebered now to inform that if your number is 100 included, you must to put {1;3} instead of {1;2}.

  132. Hi Gab and Blu

    I admit defeat on this one. I can get it to work using Gab’s instructions and substituting whole numbers for x, y, z, t, and k, but because I can’t figure out what you’re trying to achieve with the ‘k’ part, it’s got me baffled as to what you’re trying to find and then replace.


  133. When the [ is outside of a table and the ] is inside a table, the global replace with wildcard does not work.

    Selection.Find.Replacement.Font.Color = Word.WdColor.wdColorRed
    Selection.Find.Execute(“(\[)(\*)(\])”, , , True, , , , , True, “\1\2\3”, Word.WdReplace.wdReplaceAll)

    Any suggestions?

  134. Hi cgaits

    I didn’t use your macro, just the strings in the original post. It found text surrounded by square brackets WITHIN a table cell, but not across table cells (i.e. opening in one table cell and closing in another cell). It also didn’t find any matches with an opening square bracket in a table cell and its closing partner outside the table. So, I got the same results as you.

    I tried using PerfectIt (it has a function to find unclosed quote marks brackets), and it found the text after an opened (but unclosed) square bracket in a table cell, but not text with a closed (but unopened) bracket in another cell.

    I’ve reached the limits of my knowledge with this one!


  135. Thanks for taking a look. On that note, do you know of a way to search for a [ that doesn’t have any formatting? In other words, I can catch all of them except those in the case above and change their color to “red”, that leaves any I didn’t find that are “not red”. I tried searching for black [ but Word doesn’t find them. I guess because they are not technically black, but just have no specific color.

  136. I figured it out. A little extra work, but it’s working like a charm.
    oWordApp.Selection.Find.Execute(“\[“, , , , , , , , , “[“, , , , , )
    Do While oWordApp.Selection.Find.Found = True
    If oWordApp.Selection.Font.Color Word.WdColor.wdColorRed Then
    Do While InStr(oWordApp.Selection.Text, “]”) <= 0
    oWordApp.Selection.MoveRight(Word.WdUnits.wdCharacter, Count:=1, Extend:=Word.WdMovementType.wdExtend)
    oWordApp.Selection.Font.Color = Word.WdColor.wdColorRed
    End If

  137. Hi caigts

    If you didn’t want to use a macro, then a simple way would be to use a standard find/replace, with a opening bracket in both the Find and Replace fields, and with the Font color set to Auto for the Find and to Red for the Replace. That worked for me.


  138. This search feature feels so close to what I need to do, but I don’t know enough about Word and macros to figure it out. I need to find any italicized text (I do know how to do this) and insert square brackets around that text. Like this, “italicized text” changed to “[italicized text]”. I feel like this should be a pretty simple thing to do, but I’m at a loss. Any help would be greatly appreciated!

  139. Hi beckyloup

    I’m on vacation at the moment, so don’t have time to figure out more than this for now (there’s probably a more elegant way to do it):

    Do a wildcard find/replace, with () as the find (with Font: Italic selected for the find’s formatting), and replace with [\1].

    This gets you closer, but it will only find single whole words that are italicised, NOT strings of italicised text, such as paragraphs. And when it replaces, the square brackets around the text are also in italics. If you want those as normal text, you’ll need to do another (standard) find/replace for the italic opening square bracket and replace it with an opening square bracket without formatting, and then again for the closing square bracket.

    If you don’t have hundreds to do, you might be better off just looking for the italics and adding the square brackets manually.


  140. Hi, Rhonda.

    I’m trying to make a sugestion, but somethings are going wrong.
    First, I wrote this:

    “I was away for awhile and only today I saw your suggestion above.
    I’m afraid that it does not work.
    Turn on Italic Font Style (Find field)
    Find: ()
    Replace: [\1]
    returns ‘Invalid expression’.”

    When I wrote my suggestion of solution, some codes confuse the HTML syntx and it changed the final expression.

    I had to post an image elsewhere to achieve the right expression to be sent.
    This one:

    My previous posts was deleted and I suspect about some system to prevent spam.

    I hope that it can allow this one.

  141. Just in case Gab’s image ever goes missing, I’ve copied it here. He wrote a solution that requires two find and replace searches with wildcards turned on:

    Thanks Gab!


  142. wow, what a great forum. i volunteered to help someone clean up a ‘dictionary’ of useful terms they were trying to create. it was all text imported from an older database or word doc or something. i imported it in to ms office word and all the terms look like this:


    what i was hoping i could do was use the find and replace feature/tool to convert each term in to a bold listing, so the word remains, in bold, ideally with a dash after it but not required, but the [b] and the [/b] disappear. any ideas?

    can i make it look like this, in bold, same size and style font?

    Whistle –

  143. Hi, Christopher.

    Welcome to our space.

    Solution for your request is:

    Find: (\[b\])(?@)(\[\/b\])
    Replace: \2 –

    You’ll change
    Whistle –

    If you have entries with
    or other tags, just change b by i.

  144. I forgot to say:
    To get bold (or italic) on results, place cursor at “Replace” field, press “More” button, then “Format” button and then “Font” button to change whatever you want.

  145. […] a comment for this post (https://cybertext.wordpress.com/2011/06/20/word-replace-and-reformat-text-inside-square-brackets-usi&#8230;), Christopher asked how to replace a term surrounded by tags (e.g. [b]Whistle[/b]) so that the tags […]

  146. Thanks Gab! While you were posting your comment, I was writing a new post to address this issue: https://cybertext.wordpress.com/2019/04/28/word-find-a-word-surrounded-by-tags-and-make-it-bold/. I approached it a little differently, but with a similar end result.


  147. Help please: I have the original issue: Want merely to change the font color of all text located between two brackets eg [Am] – want to change the whole expression to red. I have many others to change, eg: [G]; [C]; [Bbm], etc. I am using Word with Office 365, build 1906. I have tried every find/replace permutation I have found on the internet including the various in this article – NOTHING works. I have been working on this for 2 days…no solutions. Has the syntax changed since earlier versions of Word? I can NOT fathom why it does not work. I have followed the directions slavishly. Can I call MSFT? Is there ANY help anywhere? I’m on a deadline. WHAT am I missing? Please.

  148. Hi David

    No, the wildcard syntax hasn’t changed between Word versions. I just tried the steps again, and it worked fine. I copied the find and replace strings from this post so that I didn’t type them incorrectly.

    I tried it with single words inside the square brackets, words with space between them inside the square brackets, and square brackets followed by a space then word(s) then a space then the square bracket — all worked fine.

    Make sure you have wildcards checked, and make sure only the replace field has the font colour applied to it.


  149. hello, this does not work with word 2011

  150. Hi JK

    Unfortunately, ‘does not work with Word 2011’ doesn’t help diagnose the issue. Did you get any error messages?

    Also, while I’m fairly sure that Word 2011 uses the same commands, I don’t have a Mac so I can’t test it on a similar machine or version of Word.


  151. Sorry, this does not work for me in 2007.

    Let us say, I want to change the font to Italics. Find and Replace, then, replaces EVERYTHING, including the brackets, as italicized text.

    I thought, /2 in Replace was supposed to indicate the text to be replaced, while /1 and /3 would be replace, but left alone.

    That is not happening in my case.

  152. Hi Matthew

    It works exactly as written — if you reread the intro, it says this will replace the square brackets with the font attributes too.

    If you just want to replace what’s INSIDE the brackets with italics, then you’d need a different set of find/replace commands. I’m busy with deadline work at the moment so don’t have time to figure that out right now.

    Alternatively, you could do as above knowing the square brackets will become italics too. Then run two other NON-WILDCARD find/replace routines to change the square brackets back to normal text — you’d run one for the opening bracket and a second one for the closing bracket.


  153. Can you please help me to replace text from like this:
    Universitas Gadjah Mada
    to this one:
    Universitas/O Gadjah/O Mada/O
    the idea is to replace any text inside tag with /O like that. any solutions?

  154. Can you please help me to replace text from like this:
    [Universitas Gadjah Mada]
    to this one:
    Universitas/O Gadjah/O Mada/O
    the idea is to replace any text inside square bracket with /O like that. any solutions?

  155. Hi M Ridho Putra

    You may not need to do this with a wildcard find and replace—a standard find and replace should work, assuming I’m reading your request correctly.


  156. No, what i mean is, if i have a text like this:

    I live in [South Sumatra], it is one of the province in [Indonesia]

    now i want to replace every text inside the bracket to like this

    I live in South/LOC Sumatra/LOC, it is one of the province in Indonesia/LOC

    I have tried to find with wildcard like above, and it’s worked, now the problem is how to replace it, if i just use Replace like this:
    it will only change South Sumatra/LOC , while i need the “South” word to have /LOC to : South/LOC Sumatra/LOC

    any ideas on how to do this? thanks (/\)

  157. So, why not just use a standard find and replace and find “[South Sumatra]” and replace with “South/LOC Sumatra/LOC” (NO quote marks in the find/replace — they are just for showing what to find/replace)? Does that do what you want?


  158. Hi,

    Can I ask you that what if I want to replace all the brackets which contain number only in the Word, what formula should I type in the box of “Find what”?

    Thanks in advance.

  159. Hi Simon

    To find whole numbers inside square or round brackets use one of these:

    \[[0-9]{1,10}\] – finds all whole numbers up to 10 digits within square brackets; does not find numbers with punctuation (e.g. decimal points [23.45], commas used as a separator [34.567], a minus sign in front of the number, or % after it); change the numbers inside the curly brackets to vary what it finds (e.g. {2,5} will find any 2, 3, 4, or 5-digit whole number; just {1,} will find a whole number of any length )

    \([0-9]{1,10}\) – finds all whole numbers up to 10 digits within parentheses; does not find numbers with punctuation (see above); change the numbers inside the curly brackets to change what it finds (see above)

    Update: I’ve now written a separate blog post just on this: https://cybertext.wordpress.com/2020/01/29/word-find-whole-numbers-inside-square-brackets-or-parentheses/


  160. […] the comments on my post on using wildcards to replace and reformat text inside square brackets, Simon J asked what he’d need to use to find all numbers inside […]

  161. Hi Rhonda and everyone!

    I have a document with multiple instances of the timecode format 00:00:00:00 – 00:00:00:00

    I would like to change it to 00:00:00 from the first part and ignore all the rest.

    Find & Replace with ([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2}) finds all the timecodes perfectly

    Find & Replace with ([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})\ – ([0-9]{2})(:) finds the first TC and the first part of the second TC

    Find & Replace with ([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})\ – ([0-9]{2})(:)([0-9]{2}) gives me an error (“The Find What text contains a Pattern Match expression which is not valid.” ) and I can’t get past it.

    Is there a character limit that’s preventing the formula from working or is it something else I’m doing wrong?

    Many thanks for any help!

  162. Hi Emily

    Unlikely to be a character limit, but it could be an invalid escape character string. I’ll get back to you if I figure it out.


  163. Thanks, Rhonda.

    I have tried variations of replacing the “\ – ” with ( – ), replacing the “(:)” with “\:” with the same results.

    I appreciate you taking the time!

  164. Hi again Emily

    As you only want to get rid of the final time code string, I went about it a slightly different way to just search for that. I had to use the special character for an en dash (^=) for it to work, and I couldn’t get it to work if I added a space in front of the string.

    The Find string that worked for me was: (^=)( )([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})

    This finds the second instance of the time code. You may end up with some extraneous spaces once you’ve replaced all those, but a standard find/replace should sort those out quickly.

    I’m sure there’s something you can do with the @ symbol to streamline this, but nothing I tried in the past 10 mins would work with that correctly. You just want it done, and the string above should do it.


  165. Thank you for this. The dash is just a standard dash, not an en dash and I need to get rid of the last two numbers and colon from the first TC as well. I tried modifying your code with this:

    (:)([0-9]{2})( )(-)( )([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})
    (:)([0-9]{2})/ – ([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})
    Still get an error

    Thsi variation does not give an erro, but it seaches without finding any of the text:
    /:([0-9]{2})/ – ([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})

  166. Hi Emily

    I think I’ve got it! You need to use the ANSI code for the hyphen and then it works.

    Try this for the Find: ([0-9]{2})( ^045 )([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})

    You said you wanted to get rid of the last two numbers, so leave the Replace field blank. However, if you needed to keep them, you’d have to put \1 in the Replace.


  167. Joy! That works and now I am left with “00:00:00:” If I add in the last colon from the preceding TC it throws the error again, but I can run another find and replace to get rid of the last colon. Thank you, thank you!!

  168. Hi again Rhonda.

    An update – I got it to work without running twice by using :([0-9]{2})( ^045 )([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})(:)([0-9]{2})

    Thanks for your help!

  169. Glad you got it working!

  170. Want to make greek sentences, surrounded by english sentences in word 365 doc, red color. English sentences made with the same font as the greek sentences. Alphabetum unicode for both greek and english. Like to use search replace if possible. Want red Greek. Black english which it aleady is.

  171. Trying to suggest a solution based on what I understood, use this:

    Replace: blank

    Turn Wildcard ON.
    With curson inside “Replace” field, change Font/Color to red.

    Find will select each word among the whole text and you will be prompt to replace the color accordingly. It’s necessary because we don’t know what is greek or english.

    You’ll need to make each replace one by one, not the bunch replace operation at once.

  172. This page is omitting the Find field.
    To fix that, use the following:

    Find: [less than]?@[greater than]

    Don’t consider square brackets.

  173. Dear Sir/Madam

    I am in the process of conducting researches from a book which I have downloaded in both word and pdf formats. My researches require me to extract the contents from the book to include 2 groups or strings of words from some relevant text.

    The following are 2 examples:

    Example 1
    First group (string): not only
    Second group (string): but also
    Relevant text 1:
    He is not only intelligent but also funny.
    Relevant text 2:
    Mr X is not only an actor but also a philanthropist.

    Example 2
    First group: scarcely
    Second group: when
    Relevant text 1:
    I had scarcely walked in the door when I got an urgent call and had to run right back out again.
    Relevant text 2:
    Scarcely had the teacher seen the student when he started studying.

    My question is, how would I be able to extract the relevant text of the desired strings of words which are normally consisted of 2 groupings as demonstrated in the above 2 examples. Preferably, I would like to receive instructions on how to do so from both a word document and a pdf document.

    I would like to thank you in advance.

    Preston Chow

  174. Hi Preston

    I don’t know whether you can automate such a situation with a Word macro. To do it manually (i.e. use Word to do the Find, then copy/paste the individual results into another document), I’d approach it by doing two searches, one for each of the least common words—in example 1, that would be ‘not only’, and in example 2, that would be ‘scarcely’. As you found each, you could then copy/paste the sentence to a new document.

    An alternative to this would be to do the same search but this time replace what was found with itself and highlight the term. In Word for Windows:
    1. Select a highlight colour.
    2. Ctrl+h to open the Find/Replace window,
    3. Click More.
    4. In the Find, type ‘not only’ (no quotes)
    5. In the Replace, type ‘^&’ (no quotes)
    6. Click the Format button (lower left of the window), and select Highlight.
    7. Click Find Next. On the first one found, click Replace—you should get the same word but now it will have the highlight colour you selected at step 1.
    8. Assuming you got the correct results at Step 7, click Replace All.
    9. Repeat these steps, except at Step 4, change the Find to ‘scarcely’ (no quotes) (NOTE: If you want a different highlight colour for ‘scarcely’, then select that colour at Step 1)

    What this does is highlight all instances of the terms in the document. You can then skim the document looking for the highlighted colours and then copy/paste those sentences to a new document.

    Somebody else may have a better way to do this, but this is how I’d approach it.


  175. Hello Rhonda

    First of all, thank you for your time in providing the advice above. I am not someone who knows much about computer languages so I shall be spending sometime in testing out your suggestions.

    In view of the rather substantial number of searches we need to conduct, I wonder if you could advise on the wisdom of retaining someone to write the Word Macro as a tool for us to achieve what we want done.

    Preston Chow

  176. It may well be worthwhile to see if you can get someone to write a macro for you. However, it won’t be me as this is beyond my knowledge and skill set.


  177. Hello Rhonda

    Further to my above message, on second thought, I believe it will be a good option to retain someone to produce a Word Macro, if that is considered as a possible solution. The idea is for the programmer to work out a Word Macro so that I can just enter the strings of words as described in my enquiry before in the 2 spots to conduct my searches.

    I wonder if you have the time and interest to assist? Or would you be able to recommend someone who can help? I am prepared to pay a reasonable amount for the job.

    Preston Chow

  178. As I said in my earlier reply, this is not something I can do. However, you MIGHT find that this macro can be adapted for the words you want to identify—you can add you own set of words: https://cybertext.wordpress.com/2020/02/22/word-macro-to-find-and-highlight-a-set-of-specified-words/


  179. Hello Rhonda

    I sent my latest message before reading your reply; so they are somewhat crossed.

    Would you be kind enough to recommend someone for me? Or will anyone who feels confident to perform the task be kind enough to let me know? My email address is: . I am new to this platform. I hope I am not infringing any rules by providing my email address. If so, would the Administrator of this platform take it off, please>

    Preston Chow

  180. WordPress stripped out the email address. If anyone reading this is willing to take on this task, comment below and I’ll email you Preston’s email address privately.


  181. Hello Rhonda

    As explained above, I hope you are not offended by my including my email address in my previous message. I now know the rule.

    I look forward to anyone who can help to let me know here. In this regard, kindly note that I am based in Melbourne, Australia, so there is a bit of time difference between us. Please bear with me if you do not have prompt responses from me. I shall make a point of checking on this site on a regular basis from now on.

    If there is a need for me to pay this platform for my request, please advise me.

    Preston Chow

  182. Hello,

    I hope someone can help.

    I have a document with many numbers in brackets. For instance:
    – (1)
    – (1-4)
    – (1, 5, 12)

    I would like to put all the numbers in italics, but not the brackets, not the dashes, not the commas.
    I can’t find a way to do it, knowing that I also have other brackets in the document with some text in it.

    Does anyone know if it’s possible to do this in one step or quite easily?

    Thanks a lot!


  183. Hi Laure

    A quick way is to do a wildcard search for ([0-9]) and replace with \1 then click Format > Font and choose italic. That will replace every numeral with itself, but in italics. You will replace ALL numerals with italic numerals, not just the ones inside parentheses.


  184. Hi Rhonda,

    Thanks a lot for your time and your answer.
    Unfortunately, I have also many numbers in the documents so I can’t put these in italics :(

    Thanks anyway,

  185. Hi Laure144

    I wrote another blog post that attempts to do what you’re trying to do: https://cybertext.wordpress.com/2021/12/02/word-italicise-numbers-inside-parentheses/


  186. Hi Rhonda,

    Thanks very much!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: