-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using regex for filter's argument in liquid for designer #202
Comments
I'm not sure how likely it is that this will be added to Liquid due to the security issues around regular expressions (example), but if you're working on a project where you can add custom filters, here's a simplified version of one that I use that accomplishes what you want: def regexreplace(input, regex, replacement = '')
input.to_s.gsub(Regexp.new(regex), replacement.to_s)
end This is the same as the |
Thank you, but how to put it into shopify's liquid engine. example
|
See the Create your own filters section of Liquid for Programmers on the wiki. |
Yes, a custom filter seems like a better solution here. |
Could liquid parse some filter's argument as reqex instead of normal string ?
normal string
{{ 'foofoo' | replace:'foo','bar' }} #=> 'barbar'
regex pattern
{{'foofo' | replace:/foo.*/,'bar'}} #=> 'bar'
sathit
The text was updated successfully, but these errors were encountered: