ITADN

Regex for multiline svg tags

#38Pull Requestzhengkyl 创建于 2023-09-07已合并
Z
zhengkylcommented
I had an svg that started like this and props weren't being passed into the component. ```html <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" ... etc > ``` The current regex `/(?<=<svg.*?)(>)/i` uses `.*` which doesn't match newlines. I changed it to `[^>]*` to match everything except the closing bracket. I also had trouble understanding the lookbehind, so I changed it to use a capture group and `$1`, which I think is easier to understand. Here are links to text the regex against inputs Current regex https://regexr.com/7jor9 This pull request https://regexr.com/7jorc
合并状态:已合并 合并于 2023-12-19 关闭于 2023-12-19 1 条评论