Extension talk:RegexFunctions/Archive 1

Ryan, This looks extremely useful but I can't figure out how to implement it. Could you post an example? Like maybe...

Thanks, CWinDC 06:35, 9 January 2009 (UTC)
 * Well, if you viewed the syntax notes, you'd notice that the string is passed into the function, so would yield "This is the string I wish to return." All parameters such as  are valid inside of these functions as well. -- Skiz  zerz  21:42, 9 January 2009 (UTC)

Bug: $wgRegexFunctionsDisable not working with 'rsplit' and 'rreplace'
Version 1.3 (SVN Rev 48342) RegexFunctions.php: method rmatch will check whether it is disabled in $wgRegexFunctionsDisable by doing if(in_array( 'rmatch' , $wgRegexFunctionsDisable)) return;. rsplit and rreplace also do this, except that they check for 'rmatch', too, instead of checking for 'rsplit' or 'rreplace' as expected. Thanks. This is a useful extension. - Sheepy, 09:53, 12 March 2009 (UTC)

Stack Trace Error When Installed
The following is displayed on the mediawiki main page when the plug-in is enabled in LocalSettings.php. Any ideas on how to solve this? I am running MediaWiki versions 1.15.1 and up to date MySQL and PHP. There should be no other conflicts involving other plug-ins, as I was modeling my wiki page off of another with the same set of plug-ins. Thanks!

Internal error

Magic word 'rmatch' not found

Backtrace:


 * 1) 0 /var/lib/mediawiki/includes/MagicWord.php(244): Language->getMagic(Object(MagicWord))
 * 2) 1 /var/lib/mediawiki/includes/MagicWord.php(197): MagicWord->load('rmatch')
 * 3) 2 /var/lib/mediawiki/includes/parser/Parser.php(4034): MagicWord::get('rmatch')
 * 4) 3 /var/lib/mediawiki/extensions/RegexFunctions/RegexFunctions.php(49): Parser->setFunctionHook('rmatch', Array)
 * 5) 4 [internal function]: wfRegexFunctions
 * 6) 5 /var/lib/mediawiki/includes/Setup.php(310): call_user_func('wfRegexFunction...')
 * 7) 6 /var/lib/mediawiki/includes/WebStart.php(129): require_once('/var/lib/mediaw...')
 * 8) 7 /var/lib/mediawiki/index.php(42): require_once('/var/lib/mediaw...')
 * 9) 8 {main}

Make sure that you have all of the necessary files (RegexFunctions.php, RegexFunctions.i18n.php, and RegexFunctions.magic.php). If you don't have all three of them, re-download the extension (get the "Development Version (trunk)" version from the extension distributor) -- Skiz zerz  04:43, 18 February 2010 (UTC)

Thank you for helping. I did all have three files, but tried a fresh install anyway getting the "Development Version" trunk, but it still is giving me the same error when I try to enable it in the LocalSettings.php. Everything else seems to be working just fine within the Wiki (general functions and all other installed plug-ins). Any ideas? Thanks again.
 * I'm not entirely sure how to help you since I cannot reproduce this issue -- the magic words are loading just fine for me. Perhaps some more information on your setup would help me figure out what is messing up for you:
 * PHP version
 * MediaWiki language
 * Server version (e.g. Apache 2.2 or whatever)
 * Have you edited any core files (e.g. anything that isn't called "LocalSettings.php")? If so, does reverting the changes you made to them fix the issue?
 * Please respond with the answers to these -- Skiz zerz  22:43, 18 February 2010 (UTC)

Thanks once again for helping. I am running the following versions of everything: MediaWiki v1.15.1, PHP v5.2.6-3ubuntu4.1 (apache2handler), and MySQL v5.0.75-0ubuntu10.2. I am running the following plug-ins: in Special Pages there is Replace Text and Semantic Forms, in Parser Hooks there is ArrayExtensions, LoopFunctions, Loops, ParserFunctions, SemanticMediaWiki, SMWHaloExtension, StringFunctions, Variables, and VideoFlash, and in Other there is GoogleCharts, Semantic Gardening, Semantic History, Semantic Result Formats, and StubManager. I have not edited any core files, simply LocalSettings.php and only to add all of these plug-ins.
 * OK, check through your PHP and apache's error log for something similar to "'rmatch' is not a valid magic thingy". Let me know if you find it or not. -- Skiz zerz  06:30, 19 February 2010 (UTC)

There nothing in either error log concerning "rmatch" or "magic". I apologize that this issue is so hard to diagnose/fix. There isn't anything at all popping up either in the logs at the times that I turn on the extension and try to access the page, getting the error. Please let me know if you have any other ideas on what it could possibly be or if there is any more information I can give to help in the diagnosis. Thanks!
 * I unfortunately have no idea how to fix your issue then, sorry. Perhaps it'll magically work once 1.16.0 gets released, but that's a while off still. -- Skiz zerz  08:00, 1 March 2010 (UTC)

i fix this as follow (i know it's not the best way, but it works for me) $wgHooks['LanguageGetMagic'][] = 'wfRegexFunctionsLanguageGetMagic';
 * 1) $wgExtensionMessagesFiles['RegexFunctionsMagic'] = $dir . 'RegexFunctions.i18n.magic.php';

function wfRegexFunctions { global $wgParser, $wgExtRegexFunctions; $wgExtRegexFunctions = new ExtRegexFunctions; $wgParser->setFunctionHook( 'regexmatch', array(&$wgExtRegexFunctions, 'runRegexmatch') ); $wgParser->setFunctionHook( 'regexsplit', array(&$wgExtRegexFunctions, 'runRegexsplit') ); $wgParser->setFunctionHook( 'regexreplace', array(&$wgExtRegexFunctions, 'runRegexreplace') ); } function wfRegexFunctionsLanguageGetMagic( &$magicWords, $langCode = "en" ) { switch ( $langCode ) { default: $magicWords['regexmatch']         = array ( 0, 'regexmatch' ); $magicWords['regexsplit']         = array ( 0, 'regexsplit' ); $magicWords['regexreplace']        = array ( 0, 'regexreplace' ); } 	return true; } additional i replace rmatch with regexmatch etc and the functions with runRegexmatch like this:

function runRegexsplit ( &$parser, $string = , &$pattern = , $piece = 0 ) { global $wgRegexFunctionsPerPage, $wgRegexFunctionsAllowModifiers, $wgRegexFunctionsLimit, $wgRegexFunctionsDisable; if(in_array('regexsplit', $wgRegexFunctionsDisable))