Jump to content

Topic on Extension talk:RegexFunctions/Archive 2

Migrating from Regex Fun to RegexFunctions

4
Summary by Jaideraf

Using unnamed parameters ({{#rmatch:|||}}) does not work, but using named ones does ({{#rmatch:|pattern=|then=|else=}}).

Jaideraf (talkcontribs)

Hi @Skizzerz, I am migrating from the Regex Fun extension to the RegexFunctions extension, but I couldn't get the same result from this regex, could you please help me?


Input: $a São Paulo :$b Fundação Perseu Abramo,$c 2013.

Result expected: Fundação Perseu Abramo,


Regex Fun:

{{#regex:$a São Paulo : $b Fundação Perseu Abramo, $c 2013.|/\$b(.*?)(?=\$){{!}}\$b(.*)/}}

Result: Fundação Perseu Abramo,

RegexFunctions:

{{#rmatch:$a São Paulo : $b Fundação Perseu Abramo, $c 2013.|/\$b(.*?)(?=\$){{!}}\$b(.*)/|$1}}

Result: (nothing)

Maaartyyynaa (talkcontribs)

try {{#rmatch:$a São Paulo: $b Fundação Perseu Abramo, $c 2013.|pattern=/\$b(.*?)(?=\$)|\$b(.*)/|then=$1|else=failure}} as a result I got Fundação Perseu Abramo,

Jaideraf (talkcontribs)

Thank you! You just have solved the mystery. Using unnamed parameters does not work, but using named ones does. Interesting.

Loizbec (talkcontribs)

I had the same problem after migrating from regexp fun.

I think that comes from having = in an unnamed parameter. I resorted to creating a Template:= to be able to display an '=' sign in my replacement field…

In the end, it would be better not to allow named parameters, if it makes using = sign in the regexps impossible…

Reply to "Migrating from Regex Fun to RegexFunctions"