Support RegExp groups - #18
Conversation
|
I'll try to take a look at this shortly. I'd call this a minor version change vs patch as we're adding some additional functionality. |
| @@ -0,0 +1,27 @@ | |||
| export function replacePattern(link: string, pattern: string, innerWord: string) { | |||
There was a problem hiding this comment.
nit: pattern should be RegExp to match declaration in main.ts
There was a problem hiding this comment.
Also, if you're willing, could you add some docstrings/comments to these functions to help with future development.
I need to do that for the existing code still but this could be a start.
There was a problem hiding this comment.
This change sadly introduced a bug, see #19
| }, link); | ||
| } | ||
|
|
||
| function findGroups(innerWord: string, pattern: string): string[][] { |
There was a problem hiding this comment.
nit: RegExp for pattern here as well
| | `{name}` | "words" | | ||
| | `{number}` | "123456" | | ||
|
|
||
| A link `https://example.com/{name}/{number}` would then become `https://example.com/words/123456` |
There was a problem hiding this comment.
I think this example could be clarified some more.
Maybe a sentence at the end showing what your initial input example sentence (There is some target-words-123456 in a sentence) would look like after the plugin runs.
Thanks for reviewing! |
This would add support for RegExp groups as suggested in #15
Examples (also added to README):
In a string
There is some target-words-123456 in a sentencethe patterntarget-(?<name>[a-zA-Z]+)-(?<idnr>[0-9]+)allows the following replacements:{0}{1}{2}{pattern}{name}{indr}A link
https://example.com/{name}/{idnr}would then becomehttps://example.com/words/123456