-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture groups? #58
Comments
Do you have an example regex? This library depends on the functionality of 'hey you there'.split(/( )/); // => [ 'hey', ' ', 'you', ' ', 'there' ] |
With a bit of a workaround you could the the matcher do the logic. The caveat being that the matcher regex, cannot be the same as the "parser" regex, reason being that str.split splits on capture group. const md = `
[Test](https://google.com)
`;
// Pay attention to where the matcher and parser group diffs
reactStringReplace(md, /(\[.*?\]\(.*?\))/gi, (match, index) => {
match.match(/\[(.*?)\]\((.*?)\)/gi);
return <a href={RegExp.$2}>{RegExp.$1}</a>
}); |
Speaking of, is there any legitimate way to render html containing markdown? I'm using react-string-replace to highlight some text in a string, but now I've been asked to also render any markdown contained in the string. The way I reeive the data means that the highlight-replacement must operate on the string, so I have to do that part first. If the original string contained markup, I'm left with something like the following (in array form, of course)
If it was a raw string, I could just use react-markdown or similar lib, but obviously that's not an option after the first transform. Any ideas? Even if it means combining with a different package? Btw thanks so much, this library is awesome |
Here the example:
|
Can you add support for multiple regex capture groups?
The text was updated successfully, but these errors were encountered: