iansinnott / iansinnott/react-string-replace

Multiple replacements in a string are not working properly

Đang mở
#48 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
666
Fork
54
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I am using react-string-replace for translations. I have a string and I want to replace a couple of substitutes.
The code looks like this:
```
ReactStringReplace(
'[link]This is my link[/link] available everywhere or [shortcode].',
/(\[link\].*\[\/link\])|(\[shortcode\])/g,
(match) => {
console.log('match', match);
}
)
```
From my understanding, my regular expression should match only the first link and the `[shortcode]`. But the result in the console looks like this:
```
match [link]This is my link[/link]
match available everywhere or
match [shortcode]
```
I don't understand why is the middle match there. It doesn't match the regular expression.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.