Purpose: Learn how to use pattern matching to further refine your shipping rules.
The Sendcloud subscription plans have been updated. If the subscriptions shown in the banner above don’t match your current subscription plan and you’d like to know more, please click here
How to use pattern matching
You can use pattern matching to further refine your shipping rules. Pattern matching is when a given sequence is checked to see if it contains certain characters. This is particularly useful for shipping rules related to postal codes or for including ranges of numbers such as product SKUs or order numbers, as a condition.
To begin, select Pattern matching as the operator for your condition. Enter your characters either in front or after the pattern character in the following way:
Pattern: | Meaning: | Example: |
*X | starts with any number(s)/character(s) but must end with number(s)/character(s) that are mentioned after "*" |
When postal code pattern match |
X* | ends with any number(s)/character(s) but must start with number(s)/character(s) that are mentioned before "*" |
When postal code pattern match |
*X* |
Starts and ends with any number(s)/character(s) but must contain the number(s)/character(s) that are mentioned between "*" |
When item name matches *jeans*: the shipping rule will be applied to orders with the item name such as blue jeans size M, skinny jeans black or short jeans skinny |
?X | starts with one number/character but must end with number(s)/character(s) that are mentioned after "?" |
When postal code pattern match |
X? | ends with one number/character but must start with number(s)/character(s) that are mentioned before "?" |
When postal code pattern match |
X[] | starts with number(s)/character(s) before brackets and must end with one of the number(s)/character(s) mentioned between brackets | When postal code pattern match 123[4,5,6] : the shipping rule will be applied to orders with postal codes such as 1234 , 1235 or 1236 |
[]X | ends with number(s)/character(s) after brackets, but must start with one of the number(s)/character(s) mentioned between brackets | When postal code pattern match [1,2,4]456 : the shipping rule will be applied to orders with postal codes such as 1456 , 2456 or 3456 |
X[!] | starts with number(s)/character(s) before brackets, but must not end with one of the number(s)/character(s) mentioned between brackets | When postal code pattern match 145[!6] : the shipping rule will be applied to orders with postal codes such as 1457 , 1458 or 1459 |
[!]X | ends with number(s)/character(s) after the brackets but must not start with one of the number(s)/character(s) mentioned between brackets | When postal code pattern match [!1]456 : the shipping rule will be applied to orders with postal codes such as 2456 , 3456 or 4456 |
Example: In London there are four types of postcode area: W, E, S, and N. If you want to apply a shipping rule for London, but which will only apply to addresses in the W postcode area, you could apply the below rule:
- If “Postal code” (CONDITION), PATTERN MATCH "W*" then "Ship with" UPS" (ACTION)
Related articles
→ Shipping rules overview and application
→ How to use shipping rules with Dynamic Checkout
→ Import shipping rules in bulk/CSV file