I am having an issue with an action to parse tags from Bear in the format #test/test1/ which I am testing with a #test/test1 line in a draft.
My code which fails in the action is like this:
const re = /#[\/\w\d]+/g; const masterTag = draft.content.match(re); const findRegex = /\//g; const replaceWith = "\n#"; const temp = masterTag.replace(findRegex, replaceWith);
This produces thiserror:
TypeError: masterTag.replace is not a function. (In ‘masterTag.replace(findRegex, replaceWith)’, ‘masterTag.replace’ is undefined)
When I show an alert with the masterTag variable it shows me it is indeed defined and is #test/test1. So I manually declared the masterTag variable to be also equal to #test/test1 and again it shows the same thing and not only that but with this manual declaration of masterTag the code runs OK.
So my question is what is the difference between the seemingly identical masterTags?
Thanks in advance.