Jump to content

Topic on Extension talk:Regex Fun/Flow

74.255.33.135 (talkcontribs)

How can I get this to parse the content of a variable?

Using the Variables Extension.

{{#vardefine:cur|Current user rating: 4 (1 rating)}}

The variable cur contains variable text that can look like "Current user rating: 4 (1 rating)".

Why doesn't this work?


{{#regex: {{#var:cur}} |/^.*rating: ([0-9]+\.?[0-9]*).*$/|$1}}

that returns something like "1461dee31c1648-item-1--QINU" which changes every refresh.

Thanks for the awesome extension.

Danwe (talkcontribs)

I can not confirm this.

{{#vardefine:cur|Current user rating: 4 (1 rating)}}
{{#regex: {{#var:cur}} |/^.*rating: ([0-9]+\.?[0-9]*).*$/ | $1}}

produces 4 using the current (trunk) version of Variables and Regex Fun. The "1461dee31c1648-item-1--QINU" thing you are writing about looks like a internal strip marker, something went utterly wrong there. But I can't believe this is due to simple variables/regex usage, perhaps you are using some strange version or something is interfering? Which version do you use?

Kghbln (talkcontribs)

I have seen this QINU problem before. Perhaps it is related, though I basically have no clue. Cheers

Accidently I saw another edit todoy which said: "The parser hook must return a value in MW 1.18+, so return the empty string" with return htmlspecialchars(""); Still I do not know if this is the cause of this problem.

Reply to "Parse variable"