我想知道如何才能只获取字符串的最后3个字符,其中只包含一个给定的子字符串。例如,我想获取每个在-%}前面都有子字符串"assign“或"liquid”的。在这种情况下,我只需要第1、2和8行中的-%}。
1 {%- assign weather = rain -%}
2 {%- assign num_apples = 10 -%}
3 {%- render 'thing' -%}
4 {%- liquid
5 if true
6 return
7 endif
8 -%}请注意,这是用于查找和替换。如果这有帮助的话,我正在使用ShellJS。
我似乎不能再靠近这些了:
(?=assign)*.{3}$
(?=(?<=assign )).*
(?={%- assign )(.*){3}$发布于 2022-11-07 03:37:29
https://stackoverflow.com/questions/74340547
复制相似问题