'Regex : match ass \fn font tag

I want to match all \fn tags with the following font name, so for :

\fnArial\i1

\fnArial

\b1\fnArial)

\t(\fnJester (BIG))

\t(\fnJester (BIG))\i1

\t(\fnJester (BIG)

\t(200,400,20,\i1\blur2\b1 \fnArial)\fnArial (BOLD)\i1\blur2\b1\fnArial\b1

I want to match :

Arial

Arial (BOLD)

Jester (BIG)

Like that without any more bracket or anything else.

The font name is either followed by a \ or a ) or end on string ($)

My main issue is that there are fonts that end with a bracket like Jester (BIG) and I struggle to match these along with font name that end with a bracket because of a previous \t( tag.

I managed to do this, but it's not working for double brackets.

(?<=fn)(.*?)(?=\\|(?<=\))(?=\))|(?<=\w)(?=$)(?<=\w)(?=$)|\)$) 


Solution 1:[1]

Well, I think I found the right expression :

(?<=\\\s*fn).*?(?=\\|(?<=\(.*?\)|\)))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 andiandi