iansinnott / iansinnott/react-string-replace

Multiple replacements in a string are not working properly

Aberta
#48 2 comentários 2 reações 0 responsáveis Ver no GitHub
Linguagem predominante
JavaScript
Estrelas
666
Forks
54
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Comece com a chamada a ReactStringReplace e o exemplo de expressão regular na issue; em seguida, reproduza as correspondências registradas usando a string fornecida. Rastreie como o callback de substituição é invocado e determine por que o texto intermediário é reportado; está concluído quando as correspondências reportadas e o comportamento da substituição estiverem de acordo com a expectativa declarada na issue.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript, react
Domínio
frontend
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.