Filter SMS by keyword or regex on iPhone
Short answer
iPhone has no built-in way to filter texts by keyword; iOS only blocks numbers and screens unknown senders. To filter by a word, phrase or regular expression you need an SMS filter app selected in Settings. In KleanBox, which is free, you add a rule with Rules › Add Rule, choose Word or Regex, and pick whether it looks at the message, the sender or both. Matching texts from senders who are not in your contacts go to Junk, Promotions or Transactions instead of the inbox.
What iOS does on its own
| Need | Built into iOS | SMS filter app |
|---|---|---|
| Block one number | Yes | Not needed |
| Separate senders who are not in contacts | Yes | Not needed |
| Filter texts containing a word or phrase | No | Yes |
| Filter by sender name | No | Yes |
| Filter with a regular expression | No | Yes |
Add a keyword rule
- Install KleanBox and turn it on as the filter (setup guide).
- In the Rules tab tap Add Rule.
- Choose Word and type the phrase, for example
free spins. Separate several words with commas to create one rule for each. - Under Advanced, pick the Category (Spam, Promotions, Transactions) and the Match Field (Message Content, Message Sender, Both). By default the rule looks in the message and sends matches to Spam.
- Tap Save. The rule applies from the next message on; older messages are not reclassified.
Keyword matching ignores case and accents, and treats the Turkish dotted and dotless i as the same letter, so indirim also matches “INDIRIM” and “İNDİRİM”.
No pattern writing: Guided mode
If you would rather not write a pattern, choose Guided and describe the rule; KleanBox builds the expression:
- “Starts with” or “Contains”
- “Contains a link”
- “Contains an amount”
- “Contains a numeric code”
- “Sender is a short code”
Regex examples
| Regex | Catches |
|---|---|
\d+\s*(freespin|free spin|fs)\b | Numbered free-spin offers: “100 free spin”, “250 FS” |
%\s*\d{2,3}\s*bonus | “%100 bonus”, “% 50 bonus” |
\bwin\s+(up\s+to\s+)?[$£€]\s*\d+ | “Win $500”, “win up to £1000” |
https?://\S+\.(xyz|top|click)\b | Links on particular top-level domains |
Regular expressions are matched without regard to case. An invalid expression cannot be saved, and Rule Health flags a rule that would also catch ordinary messages.
Test before you trust it
Paste a real message into the Test tab. KleanBox shows which folder it would land in and which rule or keyword decided, so you find a rule that would swallow bank or delivery texts before a real one arrives. Add senders that must never be filtered to Safe Senders; they are checked before every rule.
Limits set by iOS
- Filter apps only see texts from senders who are not in your contacts, and never iMessages.
- A filtered message is moved to a folder in Messages, not deleted.
- One filter app can be active at a time.
Frequently asked questions
Can I block texts by keyword on iPhone without an app?
No. The built-in options are blocking a number and screening unknown senders. Keyword filtering needs an SMS filter app.
Is there a free iPhone app to filter SMS by keyword or regex?
Yes. KleanBox is free and supports keyword rules, regular expressions and a guided rule builder, with no limit on the number of rules, no subscription and no ads.
Which regex flavour is used?
Apple's NSRegularExpression (ICU syntax), matched case-insensitively against the message text, the sender, or both.
Can I share my rules with someone else?
Yes. Export your rules as a file; whoever opens it in KleanBox can add them with one tap.