I have a markdown file with YAML frontmatter enclosed by “—”. It also contains “—” in the middle of the markdown because I use Obsidian’s presentation plugin where this is the slide separator.
I want to extract the frontmatter (which I have done through splitting at “—”) as well as the rest of the markdown, where I am asking for help.
I tried the following in my sub flow
- replace string with nothing: use original input, replace the frontmatter I got from the splitting. It does not find the string
- replace string through regexp: I tried this (from ChatGPT) without success
^---[A-Za-zÄÖÜäöüß\-#\[\]\(\) \n\r\t]*---$
- concatenate the splitted list: here I do not know how to start at index 2 or 3, and secondly the separator is not used.
Any idea? The input looks like this:
---
tags:
- "#Lektion"
- Bewegung
- Aufnahme
title: Test 2 Gefühl
parent: "[[test1]]"
status: published
description: Ein Satz zu Lektion1 aka test2
slug: test-2-gefuehl
---
# Actual Content
after frontmatter
## a heading
begin slide 1
with [[test1]] Link
---
## Slide 2
more content
...
corrected the regexp, now it is working:
^---([A-Za-zÄÖÜäöüß0-9\n\r:\- \t"#\[\]\(\)]*?)---(\n)*
I still don’t understand why the first option does not work or how to do the third, so if anyone can shed light on those I’d still be grateful.
The first string replacement approach failed because you’re trying to match a multiline block (the YAML frontmatter) using a plain string replacement, which doesn’t interpret line breaks or special characters properly.
Here’s why that matters:
1. Plain String Replacement Limitation
When you use the basic replace function (not regex), it expects an exact match, including line breaks, spaces, tabs, etc. YAML frontmatter usually contains multiple lines with varying indentation, making it nearly impossible to match the full block as a single string.
So unless your frontmatter is formatted exactly like the string you’re trying to replace (down to each space, newline, and character), it won’t find a match.
2. Multiline Matching Requires Regex
You need a regular expression with multiline and dot-all support, because:
- Multiline mode allows
^
and $
to match the start/end of lines.
- Dot-all mode (
(?s)
or using a non-greedy match like *?
) lets the dot match line breaks.
That’s why your updated regex works:
^---([A-Za-zÄÖÜäöüß0-9\n\r:\- \t"#\[\]\(\)]*?)---(\n)*
This pattern:
- Matches the starting
---
- Non-greedily captures everything in between
- Stops at the next
---
on its own line
- Also includes the trailing line breaks
3. Why Concatenate with Index Didn’t Work
When you split on ---
, the frontmatter usually ends up at index 1, and your content starts from index 2 or later. You mentioned not knowing how to start at a specific index—this part needs a manual step because Activepieces doesn’t (yet) support slicing and joining arrays directly in standard blocks.
To get around that, you can add a small code step and use something like this:
return items.slice(2).join('---');
That skips the frontmatter and rejoins everything after it, putting the separators back in. Adjust the slice index depending on where your actual content starts.
Never thought of that option.
Activepieces next level.
Thanks for the idea (as well as the thorough reply which points me to regexp jargon I need to do more research on), I already have an idea where else I could use that (making a slugify that converts to lowercase).
1 Like
@juliuspopp,
I am not sure if you have seen it, but there is already a piece that helps with many of these tasks you want to achieve called Text Helper:

Kind regards,
Yes, I am using those functions, but slugify is a bit limited for my use case.
1 Like