Hello
I need some help with the following formula. I want to format specific words in a text based on a list. The list looks like this:
| Kursiv |
Fett |
Name |
| j |
n |
Name 1 |
| n |
j |
Name 2 |
If the “Kursiv” column contains a “j”, the word should be formatted in italic.
If the “Fett” column contains a “j”, the word should be formatted in bold.
I’ve written the following formula, and it works, but it doesn’t handle words that appear before punctuation marks. Does anyone have an idea how I could fix that?
thisRow.[Mechanik TB1].Split(" “).FormulaMap(
WithName(CurrentValue, Word,
WithName([Format List].Filter(Name = Word).First(),Match,
If(Match.IsBlank(),Word,
If(Match.Fett = “j” AND Match.Kursiv = “j”,_Bold(_Italicize(Word)),
If(Match.Fett = “j”,_Bold(Word),
If(Match.Kursiv = “j”,_Italicize(Word),
Word))))))).Join(” ")
Thanks in advance!
hi @Nebular_Productions , it has been a while, good to see you back again 
would you mind adding a sample doc and part of that is how the expected end result should look like, based on what you wrote i don’t understand the issue.
cheers, christiaan
Hey Christiaan, thank you!
Sure. Here is a little Test Doc 
hi @Nebular_Productions ,
well, this is complicated work that i normally do for a living, but since I engaged in this thread I solve it for you and I hope others benefit from it as well.
the code
// Extract all segments from the text using regex pattern
thisRow.[Mechanik TB1].RegexExtract(
// Build regex pattern that matches:
// 1. Format names from Format List table (with word boundaries)
// 2. Punctuation marks separately
// 3. Other word sequences
// 4. Whitespace
"(\b(?:" + [Format List].Name.Join("|") + ")\b)|[,\.;:!?]|[^\s,\.;:!?]+|\s+",
"gi" // Global, case-insensitive matching
)
// Process each extracted segment
.ForEach(
CurrentValue.WithName(segment,
// Look up the segment in Format List table to check if it needs formatting
[Format List].Filter(Name = segment).First().WithName(match,
If(
// If no match found, return the segment unchanged
match.IsBlank(),
segment,
// If match found, apply formatting sequentially
segment
// Step 1: Apply italic formatting if Kursiv = "j"
.WithName(FormattedText,
If(match.Kursiv = "j",
_Italicize(FormattedText),
FormattedText // Pass through unchanged if not italic
)
)
// Step 2: Apply bold formatting if Fett = "j"
// This operates on the result from Step 1, so both formats can be applied
.WithName(FormattedText,
If(match.Fett = "j",
_Bold(FormattedText),
FormattedText // Pass through unchanged if not bold
)
)
)
)
)
)
// Reconstruct the complete text by concatenating all segments
.Concatenate()
cheers, christiaan
Wow, that’s absolutly amazing and work perfectly for me. Thank you so much! 
you seem to be surprised that it all works just fine @Nebular_Productions 
out of curiousity, who wrote the inital code and what was the inspiriation for it ?
cheers, christiaan
One thing I recommend to not be done is use static values inside formulas (I mean the j, k etc.) since when needs change… you’ll have to hunt things inside which and where are the formulas.
Not surprised – just hyped! 
It actually solved a big problem for me.
I wrote the first formula using my basic knowledge and a bit of help from Claude AI. For me, understanding regex formulas and the Formulamap function is still a bit tricky.
My use case is some mechanic texts of our card game that we’re developing — I wanted specific keywords to be automatically highlighted in the text. 
Best regards from Germany
Frederik
thanks @Nebular_Productions for sharing the insight, I was wondering (based on the syntax) who would have thought of this solution in this specific way. Good that the AI served you well, in my experience an AI needs a bit more specific guidance to work really well. I wrote about it earlier this morning and in the blog I reference a pack I wrote to find and replace words in a text while keeping the mark up. Enjoy your working day, cheers, Christiaan (Gent, Belgium)
That’s so cool that you wrote a blog post about this niche case! It’s always interesting to see detailed how others approach these kinds of challenges. When it comes to AI, it really does take some trial and error to figure out the best way to get the results you’re aiming for. Thanks for sharing your experience — and good to know about your plugin, I’ll definitely check it out!
Best regards
Frederik
bravo @Christiaan_Huizer, well done indeed.
this is exemplary community support at the highest level.
max