(I'm not associated with the app, but this is basically what I wish was built in to iOS, and it's OSS, free, ad-free, and implemented entirely on the device)
Source: https://github.com/afterxleep/Bouncer
From the app listing:
> Bouncer a simple SMS and MMS filtering app that moves unwanted messages to the "Junk", "Promotion" and "Transaction" sections of the Messages app.
> Different to other apps, Bouncer does not share, upload or send any of your personal information or SMS messages to a remote server. All the filtering happens locally on your phone, based on your own private word or regular expression list.