Strip out variable-length string from selected text (for legal case cites)

As a lawyer, I use a special citation format for cases. For example:

Strickland v. Washington, 466 U.S. 688 (1984)

Turpin v. Hill, 269 Ga. 302 (1998)

When I have to cite to a particular page in the decision, I write something like:

Turpin v. Hill, 269 Ga. 302, 304 (1998)

Sometimes, I want to be able to highlight this kind of case cite and strip out the pinpoint page reference. In the above example, I want to strip out “, 304” so that I’m back to the original case cite format: Turpin v. Hill, 269 Ga. 302 (1998)

I know how to create a macro that searches and replaces (or deletes) strings in the clipboard. I don’t know how I would search the clipboard and strip out a string that includes the comma following a numeric digit (in this case, a 2), the space after that comma, and the next set of digits which could be from 1-4 characters long, arbitrarily (because the page numbers I want to delete could be single digit or up to four digits long).

H’ep me!


Hi Brian,

Something like this does the job:

Also to have a look to

can help.


Thank you very much. I will tinker with this!

This worked just right:

Now I can highlight any case cite with a page reference and immediately strip it out. (In the following example, I'm working in MS Word. I found that with some case cites in Word, the reporter cite (e.g., "U.S.", "Ga." lost formatting, so I put a clipboard remove-style filter into the workflow, which solved the problem, except that when you highlight the whole cite you lose the formatting for the case title. Bottom line is you don't have to highlight the whole cite. Of course, it works without a hitch in plain text.) This makes my life much easier. Thanks folks - here's a demo:

Hey Brian,

This seems to work without interfering with the formatting in Word 2011.

Reformat Legal Citation.kmmacros (2.4 KB)

I've changed the regular expression, so only strings like 302, 304 (1998) are seen:

And reduced to:

302 (1998)

That should prevent problems with citations like:


1 Like

I want to thank folks for their thoughtful responses. I have learned a lot about regular expressions with this task. I’ve finally constructed a macro that I think can account for all possible permutations of a case cite.

One of the issues I had to overcome was the possibility of things like page ranges (“304-06”) or references to footnotes (“n.1”). These strings contain non-numerical characters and so I had to use /S rather than /d to account for those possibilities. The other permutation was the possibility of multiple page references, separated by commas: Turpin v. Hill, 269 Ga. 302, 304, 306-07, 308 (1998). To get that kind of long cite back to the basic cite the macro had to loop through repeated checks of the clipboard string, removing references one by one.

The final macro “STRIP PINPOINT CITE” incorporates two sub-macros ('STRIP COMMA" and “STRIP FIRST CITE”) which are called depending on the state of the clipboard string. I have saved them into a macro library which you can download here. I would love to hear your critiques.

Try the macro by using the examples below. For each one, select the entire string or, at least, start the selection at the number before the second comma in the string and include at least the first parenthesis in the string.

Ferrell v. Head, 201 F.3d 1124, 1125, 1134, 1136 (11th Cir. 2013)

Buchanan v. State, 523 P. 2d 1134, 1125, 1124-34 (Okla. Crim. App. 1974)

Turpin v. Hill, 269 Ga. 302, 304, 306 n.1 (1998)

Hey Brian,

Give this pattern a try in my previous macro:


(, \d+[^,\n\r]*)(?:, \d+[^,\n\r]*)*(\(.*?\d{4}\))


$1 $2


As you may have gathered, I was deeply uneducated as to regular expressions. After a lot of work, I constructed a pattern that works in just about every circumstance, where only one case reporter cite is in play. Below is the basic macro being used to take a long pinpoint cite and reduce it to its basic citation format.

The sample case cite is:

Wilcox v. Sec’y, Dep’t of Corr., 158 F.3d 1209, 1210-11, 1213 n.3 (11th Cir. 1998)

The macro reduces it to the basic cite:

Wilcox v. Sec’y, Dep’t of Corr., 158 F.3d 1209 (11th Cir. 1998)

Below is another macro that strips S.Ct. and L.Ed. reporter cites from Supreme Court case cites in legal texts. When I’m writing a brief, I often need to copy case cites out of a published legal opinion. U.S. Supreme Court cites usually include all three official reporter cites, but for a brief I only need the U.S. Reporter cite. So, copying and editing the cite is tedious and time consuming. This is what I’m talking about:

I want that cite to look like this:

Williams v. Taylor, 529 U.S. 362, 405 (2000)

This macro does it with a keyboard shortcut:

Hey Brian,

Well done.

RegEx is a handy tool to have in your toolbox.


1 Like

It has been a revelation. These tools will save me literally hours of wasted time when writing legal documents… Thanks for the guidance.