Jump to content

Extension talk:RegexFunctions

About this board

Previous discussion was archived at Extension talk:RegexFunctions/Archive 1 on 2020-03-22.

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"

Would be amazing if there was an {{#rswitch:}}

1
TaylanKammer (talkcontribs)

I'm thinking of something like this:

{{#rswitch: STRING
| REGEX_1 = RESULT_1
| REGEX_2 = RESULT_2
...
}}

Should be pretty self-explanatory what it's meant to do. The result parts should be able to reference capture groups. Basically, it would be like a bunch of nested rmatch usages.

Reply to "Would be amazing if there was an {{#rswitch:}}"

#rsplit shows last piece, even when piece number is greater than last

1
ZyMOS (talkcontribs)

When looping through all pieces using #rsplit there is no easy way to know when your at the end.

for example

#rsplit: bob,taco,beep|,|

piece 1: bob

piece 2:taco

piece 3:beep

piece 4:beep

piece 5:beep

...

Reply to "#rsplit shows last piece, even when piece number is greater than last"

Where is the extension.json file?

2
Qpn6ph9q (talkcontribs)

There is no extension.json file in the tarball. This causes the wiki to abort with an error when the extension is loaded as directed.


PHP message: PHP Fatal error:  Uncaught Exception: Unable to open file /path/to/RegexFunctions/extension.json

Qpn6ph9q (talkcontribs)

I eventually found it on the github repo.

Reply to "Where is the extension.json file?"
There are no older topics