iansinnott / iansinnott/react-string-replace

Multiple replacements in a string are not working properly

オープン
#48 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
666
フォーク
54
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。