User talk:Mglovesfun/vector.js

Latest comment: 13 years ago by Mglovesfun in topic Documentation

Documentation edit

This vector uses a lot of regular expressions to do automatic text replacement. Do feel free to discuss these replacements on this talk page, but please don't remove things unless absolutely necessary. Mglovesfun (talk) 13:57, 30 March 2011 (UTC)Reply

Useful stuff edit

Character range, to match any text excluding line breaks, and the wikisyntax [, ] or |:

([\ -9\;-\\\^-z\}-\-]+)

Context label redirect snapper:

 txt=txt.replace(/([\|\{])insert([\}\|])/g, "$1insert$2");

Removed stuff edit

Stuff that used to work, and now doesn't edit

Stuff that doesn't work anymore than should ideally be put back if MediaWiki ever allows it again

 txt=txt.replace(/\[http\:\/\/en\.wikipedia\.org\/wiki\/([a-zA-Z0-9\_\-\:\'\(\)\"\/]*)\ ([a-zA-Z0-9\_\-\:\'\(\)\"\/\ ]*)\]/g, "[[w:$1|$2]]");

Stuff that doesn't work/is too buggy edit

  txt = txt.replace(/''\[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\]''/gi, "{{term|$1}}");
 txt=txt.replace(/\\{\{it\-noun\|([\ -9\;-\\\^-z\}-ퟻ]+)\|([\ -9\;-\\\^-z\}-ퟻ]+)\|([\ -9\;-\\\^-z\}-ퟻ]+)
\|([\ -9\;-\\\^-z\}-]+)\}\} ''[fF]eminine'' '''\[\[([\ -9\;-\\\^-z\}-ퟻ]+)\]\]'''/g, "{{it-noun|$1|$2|$3|$4|f=$6}}");

That works, removed anyway edit

//Remove now-useless {{cardinal}} and {{ordinal}}, such information goes in the header or definition line
  txt = txt.replace(/\{\{(cardinal|ordinal)(\}\}|\|)/gi, "{"+"{subst:blank$2");

Stuff I haven't even tried yet edit

txt=txt.replace(/\{\{infl\|ko\noun\|tr=([a-zA-Z\.\ \-]+)(\}\|)/gi, "{{ko-noun|rv=$1$2");
txt=txt.replace(/\{\{ko\-noun\}\} \(([a-zA-Z\.\ \-]+)\)/gi, "{{ko-noun|rv=$1}}");
Return to the user page of "Mglovesfun/vector.js".