Reputation: 9
On notion i am trying to create a formula. that uses replace inside of a replaceall with a regex im having an issue on putting the prop value inside the double quotes in the replace.
The code in working state;
replaceAll(replace(prop("all chapter numbers"), "(?:[^,]*,){2}", ""), ",.*", "");
What i am trying to accomplish to
replaceAll(replace(prop("all chapter numbers"), "/(?:[^,]*,){prop("total checked chapter")}", ""), ",.*", "")
I have tried to use the template literal instead of the simple quotation. Which resulted on notion formula not recognizing the code and simply telling me " needed.
Because i had no clue about JavaScript and template literal i have did some research and try to replicate from the examples.
Firstly because notion reaplace formula looking much diffrent that what i have seen on javascript sites i tried to do it on one replace then add the other one afterwards.
replace("Visit Microsoft","Microsoft","W3Schools");
javascript examples i have seen
let text = "Visit Microsoft!";
let result = text.replace("Microsoft", "W3Schools");
implementing onto my issue
Try1:
replace(prop("all chapter numbers")),`(?:[^,]*,)${prop("total checked chapter")}`, ``)
Output syntax error
replace(prop("all chapter numbers"),`(?:[^,]*,){${total checked chapter}}`,"" )
I have checked this question
That i have to use new regExp but i got no info on the web how to use a newregex on the syntax of notion replace formula.
from the w3 school example i tried to put my prop/string value with ${}
replace(prop("all chapter numbers"),"(?:[^,]*,){${total checked chapter}}","" )
but in this one it did not saw my value and counted as 0 so the result
if i try to change the "" double quotes like this
replace(prop("all chapter numbers"),`(?:[^,]*,){${total checked chapter}}`,"" )
it will give me the same syntax issue on the other examples like this
i even tried another solution i have seen that uses '\b{replacethis}\b'
replace(prop("all chapter numbers"),`\\b${total checked chapters}\\b` , "")
Upvotes: 0
Views: 45