Coder Social home page Coder Social logo

kas-elvirov / regexify-string Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 3.0 706 KB

Strings decorator with: React components, HTML tags etc.

Home Page: https://www.npmjs.com/package/regexify-string

JavaScript 32.05% TypeScript 67.95%
decorator html-tags react-components regex

regexify-string's Introduction

привет 👋

👩‍💻 About Me

I'm frontend developer with economic education from Russia

🛠 Language and tools

react logo nodejs logo javascript logo flutter logo dart logo

🔥 My Stats :

languages graph
streak graph

regexify-string's People

Contributors

dependabot[bot] avatar kas-elvirov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

regexify-string's Issues

regexifString crash at some scenarios

In some scenarios, the regexifString crashes the browser.
ex:

console.log(

    "regexifyString test",
    regexifyString({
      pattern: /.*/gim,
      decorator: (match, index) => {return 'ReplaceMe';},
      input: "This is a test",
    })

 );

I did a simple debug in the function implementation and found if (match === "") break inside the

while (result !== null) {

    const matchStartAt = result.index;
    const match = result[0];
   ...

}

solve the issue. Can you please consider including this fix?

TypeError: processedInput.substring is not a function

hi
i used couple of patterns for 1 text and I got an error
how can I use this multiple time ?

const content1 = regexifyString({
    pattern: bold_regex,
    decorator: (match, index) => {
      return (
        <span key={index} style={{fontWeight: 'bold'}}>
          ${match}
        </span>
      );
    },
    input: content
  });
const content2 = regexifyString({
    pattern: bold_regex,
    decorator: (match, index) => {
      return (
        <span key={index} style={{fontWeight: 'bold'}}>
          ${match}
        </span>
      );
    },
    input: content1
  });

Matching groups?

I couldn't find a way to match groups. For example:

regexifyString({
    pattern: /\[(?<id>.+)\]\{(?<name>.+)\}/g,
    decorator: (id, name) => (<item b={id} c={name} />),
    input: 'a[b]{c}',
})

// to output:
// [ 'a', <item b='b' c='c' />, '']

Is this possible?

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.