Giter VIP home page Giter VIP logo

Comments (6)

iansinnott avatar iansinnott commented on July 17, 2024 1

Agreed, I pushed a change that should fix this. Thanks for raising the issue. Will publish in next version.

from react-string-replace.

Kosurij avatar Kosurij commented on July 17, 2024

My solution - https://github.com/iansinnott/react-string-replace/pull/75

@iansinnott, please check it.

from react-string-replace.

alex-clear avatar alex-clear commented on July 17, 2024

Have the same issue with next Regex: /({phone})|({name})/gi
Then var result = str.split(re); - provides next result: ['Please enter the code we sent to you at
 ', '{phone}', undefined, '', undefined, '{name}', '. ']

The solution for this can be next fix: var result = str.split(re).filter(Boolean);
@iansinnott Can you fix this one?

from react-string-replace.

iansinnott avatar iansinnott commented on July 17, 2024

what's the str value?

from react-string-replace.

iansinnott avatar iansinnott commented on July 17, 2024

I think your regex is not doing what you expect. try using only one matching group with | to separate alternative matches.

Use https://regex101.com/ for quick iteration testing regex

from react-string-replace.

alex-clear avatar alex-clear commented on July 17, 2024

@iansinnott Thanks for remark. You are right, there was an issue with our regex
however, IMO, in order to prevent error throws, better to add the solution above(or in existed PR), or to add try catch to the code(maybe return error with 'wrong regex provided' or something similar)

from react-string-replace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.