Published
Edited
Jun 25, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{ return {
name: "${name}",
$filters: [
{
fn: "replace",
path: "name",
pattern: "Ben\\b",
value: "Benjamin"
}
]
}}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function oneToTwo(s) {
if (s[0] === "'") {
return '"' + s.substr(1, s.length - 2).replace(/(?!\\)"/g, '\\"') + '"'
} else {
return s
}
}
Insert cell
Insert cell
function bizarro(s) {
return JSON.parse(s.replace(quoteRegExp, oneToTwo))
}
Insert cell
Insert cell
Insert cell
Insert cell
{
let match = /^\$\{\s*\$filters\.([$_a-zA-Z][$_a-zA-Z0-9]*)\(([^,]+),(.*)\)\s*\}$/g.exec(example3.name)
return {
fn: match[1].trim(),
path: match[2].trim(),
...bizarro(match[3])
}
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more