Closed Yakutoc closed 7 months ago
The custom_placeholders
use javascripts replace
method.
As far as I can observe, I suppose you would expect it to use match
instead?
(debugger preview with match in use, which would do what you expect)
you would expect it to use
match
instead
Yep =)
I expected that 1$
is the result of a regular expression and that it will replace its BODY.
Is it even possible to do this?
Unfortunately the replace
function of JavaScript works differently
You can best test its behavior here for example: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
const paragraph = "## Release Notes\n\n### Dropdown\n\nsome text\n\n### What/why Changed\n\nsome text\n\nsome text";
const regex = /(?:## Release Notes)(.*)(?:### What\/why Changed)/s;
// this is the behaviour within the action
console.log("FIRST EXAMPLE");
console.log(paragraph.replace(regex, '$1'));
// this would be the result of match (which returns an array, and has no target)
console.log("SECOND EXAMPLE");
console.log(paragraph.match(regex));
// the index 1 result of the match array
console.log("THRID EXAMPLE");
console.log(paragraph.match(regex)[1]);
I would love to find a better solution with javascript which would work like match, and has the support for the "target" - as that would most of the times be the most convenient way of doing things.
Thanks for your answers and help.
I decided to do it differently.
I'll just cut out everything that comes after "### What/why сhanged"
"custom_placeholders": [
{
"name": "DESC",
"source": "BODY",
"transformer": {
"pattern": "(?:\n### What\/why сhanged)(.*)",
"flags": "s",
"target": " "
}
}
]
Hello, could you please help me to understand how to do it right?
There is this body in my pr
And I would like to take only part that is between
## Release Notes
and### What/why Changed
In the documentation I've found information about
custom_placeholders
This is part of my configuration
I don’t understand what I’m doing wrong
I expect to see this result
I would be grateful for your help!