GetCredits

From Sega Retro



Mie Kumagai

who can write the best algorithm???

Given "text" and "name", find role. We don't have Regex. GO -Black Squirrel (talk) 13:58, 10 August 2017 (CDT)


//Squirrel's "can't be arsed after a long day's work" attempt #1

while not at end of string
{{#vardefine:namePos|{{#pos:{{#var:text}}|{{#var:name}}}}}}
rpos ''':
rpos *'''
get the role
{{#vardefine:namePos|{{#pos:{{#var:text}}|{{#var:name}}|{{#var:namePos}}}}}}
etc.

My attempt

{{#vardefine:text|{{#replace:{{#var:text}}|*'''|* '''}}}}{{#vardefine:text|{{#replace:{{#var:text}}|**|}}}}
{{#loop: i
| 0
| {{#expr:{{charcount|{{#var:text}}|* '''}}-1}}
| {{#vardefine:subtext|{{#explode:{{#var:text}}|* '''|{{#var:i}}}}}} {{#if: {{#pos:{{#var:subtext}}|{{#var:name}}}} | {{#vardefine:role|{{#explode:{{#var:subtext}}|:|0}}}} }}
}}
{{#var:role}}



- Hivebrain (talk) 14:35, 10 August 2017 (CDT)

In theory it works, in practise I think it's a bit too slow (even with the replaces taken out at the start) -Black Squirrel (talk) 15:57, 10 August 2017 (CDT)



Yeah so I ran into the same problem as soon as I introduced a loop - the server can't cope. Though maybe the loops extension is broken in some way, idk.
It's also picking up references when it shouldn't be. I quite like the idea of passing references through, but not like that.
tbh I think every page is going to need templating and sectioning up the arse, and I'm not sure I have the patience. Hmm... -Black Squirrel (talk) 13:07, 11 August 2017 (CDT)