How to remove sizes quickly in crochet or knitting patterns

This article is a little technical, but it is written so I don’t forget how to easily make my patterns more accessible to my clients.

This will remove the tedious task of highlighting the relevant numbers for each size the maker wants to use, so they can concentrate better on the making, instead of swimming in a sea of numbers.

The method is courtesy of my SO, who’s a programmer and knows a lot more about regular expressions than me, who’s only just explored the limits of the features in simple word processor software.

If your sizes are in the format 14, 6, 15 (11, 5, 16) [19, 7, 34] {30, 22, 18} (for example, but any format works), you can use Regex to find and remove the extra numbers for each size.

You will have to repeat this process for each size.

First create a template with all the common instructions and add extra paragraph breaks before and after all the headings.

Create a copy for each size and give it a proper name (I’m using Size 1, Size 2 etc.). You can later on integrate all of these into one file.

Use a Regex compatible software (I’m using Studio Code Server embedded in Home Assistant, but you can also use Visual Studio Code or the website Regex101).

Copy the text from one size into the Regex text editor to begin replacing/removing the excess sizes.

Then use the Replace option in the program to write out a regular expression.

In my case, I want to remove everything except the first value.

My regular expression looks like this:

(\d+), \d+, \d+ \(\d+, \d+, \d+\) \[\d+, \d+, \d+\] \{\d+, \d+, \d+\}

The first element of the list is surrounded by the round brackets and that’s what I want to keep.

In the Preserve case underneath the field for the regular expression (second box in the screenshot below), I input $1, which will preserve the first element I highlighted.

The second element is selected for preservation in this screenshot (surrounded by round brackets).

You can highlight all the elements, if you want, then reuse the expression for all the sizes and input the number of your chosen size in the Preserve case, such as $1, $2 and so on.

First test that the regular expression works. It should highlight all the instances in the pattern where the expression occurs.

You click Replace all or press Ctrl+Alt+Enter on your keyboard to replace all the instances.

You’ll end up with a cleaned up pattern with only one size.

Copy this text and put it back into your text editor.

You will lose all formatting, as this edits plain text.

Use the paragraph breaks before and after the headings to find them and style them (I just apply a heading style).

Use the find and replace feature in Word to make any formatting edits.

In my case, I want all rows to be highlighted with the text Row x. to be bold.

Use the following formula for making all the row numbers bold: Row*.

Turn on “Use wildcards” and for the replace box change the formatting to what you want (I chose bold).

image 1

Now repeat this process for all the other sizes and don’t forget to add a table of measurements at the beginning of each size, so people can easily choose which part of your pattern to print or follow along with.

Hope this helps, at least future me if not any more crochet or knitting pattern designers.



Leave a Comment