MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Relay_email_to_gmail_(msmtp,_mailx,_sendmail",
        "continue": "gapcontinue||"
    },
    "warnings": {
        "main": {
            "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
        },
        "revisions": {
            "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
        }
    },
    "query": {
        "pages": {
            "1991": {
                "pageid": 1991,
                "ns": 0,
                "title": "Redmine",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "{{Draft}}\n\nNOTE: all of this page are out of wync, new packages are ruby-unicorn that includes a redmine example file.. \n\nNOTE: Alpine 2.5+ installations need to follow installation instructions for version 2.1.2 at the bottom of this page.\n\nNOTE: This is a complete rewrite of our Redmine install how-to. Previously, Ruby packages needed by Redmine needed to be installed manually with rubygems. Now we have Ruby packages needed for Remine in our repository. As of writing, ruby packages are maintained in testing repository.\n\n=Some assumptions=\n\n* For this how-to we assume you are running an Hard-disk install of Alpine Linux. If you are running from RAM, please make sure you use LBU.\n* Alpine Linux uses Lighttpd as default web-server. Redmine will be running with FastCGI inside Lighttpd. If you like to install Redmine with any other web-server, you will need to install it manually. Which are currently: ruby-rails ruby-fcgi ruby-rmagick ruby-i18n ruby-openid rubygems\n* We are using MySQL as database for our Redmine install. Redmine is also able to run with PostgreSQL or SQLite.\n* MySQL is running on a remote location. Please follow other tutorials on how to setup MySQL.  (need link).\n* Detailed information regarding Redmine installation can be found: https://www.redmine.org/projects/redmine/wiki/RedmineInstall\n\n\n=Installing Redmine=\n\n{{Cmd|apk add redmine}}\n\nOn a Alpine base install this should pull in approximately 50 packages including (almost) all Ruby dependencies and Lighttpd. If you like to run a different webserver, you will need to skip redmine package and install all deps manually with apk.\n\n=Database support=\nRedmine supports various database backends. Here we will only cover MySQL and PostgreSQL.\n\n== Option 1 - MySQL ==\nFor Redmine to communicate with MySQL server we will need to have the mysql ruby package. (if you want to run another db, just install the appropriate db package).\n\n{{Cmd|apk add ruby-mysql}}\n\nNow before we continue we need to prepare our database. According [https://www.redmine.org/projects/redmine/wiki/RedmineInstall Redmine website] you need to do the following:\n\n{{Cmd|create database redmine character set utf8;\ncreate user 'redmine'@'localhost' identified by 'my_password';\ngrant all privileges on redmine.* to 'redmine'@'localhost';}}\n\nIf you need mysql client, you can install it like this:\n\n{{Cmd|apk add mysql-client}}\n\nYou can of course also use a tool like phpmyadmin to create the database and setup the user.\n\n== Option 2 - PostgreSQL ==\n{{Cmd|apk add ruby-pg postgresql}}\n\nInitialize and start database engine:\n{{Cmd|rc-service postgresql setup\nrc-service postgresql start}}\n\nCreate redmine db user, replacing 'redminepw' with your own password:\n{{Cmd|psql -U postgres -c \"CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'redminepw' NOINHERIT VALID UNTIL 'infinity';\"}}\n\nCreate the redmine database (note that you need template0 for UTF8):\n{{Cmd|<nowiki>psql -U postgres -c \"CREATE DATABASE redmine WITH ENCODING 'UTF8' OWNER=redmine TEMPLATE = template0;\"</nowiki>}}\n\n=Redmine config files=\n\nRedmine default config files are located inside /etc/redmine. For Redmine to find your database, please edit database.yml. We have removed all entries accept the default production one. For examples please check: /var/www/localhost/htdocs/redmine/config\nIf you need to edit additional configuration files, please move them to /etc/redmine and link them back to the original location. This way apk will use config protect and not overwrite your config files on update. Don't forget to edit the other files, like your SMTP configuration in configuration.yml.\n\nFirst we need to generate a session store secret:\n\n su -pc \"cd /var/www/localhost/htdocs/redmine; /usr/lib/ruby/gems/1.8/bin/rake generate_session_store\" lighttpd\n\nNow we populate the database:\n\n su -pc \"cd /var/www/localhost/htdocs/redmine; RAILS_ENV=production /usr/lib/ruby/gems/1.8/bin/rake db:migrate\" lighttpd\n\n=Setup Lighttpd=\n\nNow our database is ready, we need to configure Lighttpd. We have included an example Redmine/Ligghtpd configuration based on FastCGI. You can find it in /etc/lighttpd.\nWhen you are finished setting up Ligghtpd configuation include it inside lighttpd.conf and we can start it.\n\n{{Cmd|vi /etc/lighttpd/redmine-virtual.conf}}\n\n{{Cmd|vi /etc/lighttpd/lighttpd.conf}}\n\n  ... \n  include \"redmine-virtual.conf\"\n  ...\n\n{{Cmd|rc-service lighttpd start}}\n\nIf your server does not run, you can find information in /var/log/lighttpd. If that does not provide a clue you can also run Lighttpd in foreground. It should display some more debug information.\n\n{{Cmd|rc-service lighttpd stop\nlighttpd -f /etc/lighttpd/lighttpd.conf -D}}\n\n= Enabling Email to Ticket =\n''Note:'' This configuration is not very secure in that it uses out of the box postfix configuration.  It's assumed that additional configuration will be applied to postfix, but that is outside of the scope of this section.\n\nFirst, add postfix.\n{{Cmd|apk add postfix}}\nAdd aliases to /etc/postfix/aliases (replace url with your URL and InsertKeyHere with your Redmine key):\n test: \"|ruby /var/www/localhost/htdocs/redmine/extra/mail_handler/rdm-mailhandler.rb --url https://bugs.alpinelinux.org --key InsertKeyHere --project=test --unknown-user=accept --no-permission-check\"\nCreate aliases db\n newaliases\nStart Postfix\n rc-service postfix start\n rc-update add postfix\n\n=Optional: Enable Email to Ticket for Unknown Users=\nNote: To enable email to ticket creation from unknown users/email addresses (after allowing anonymous issue creation within Redmine UI) for the 'myproject' project in Redmine, create the following script and have your email server pipe new emails to this script:\n\n  #!/usr/bin/perl\n  # Author: Jeff Bilyk\n  # March 2, 2011\n  #Script to take email from stdin, then:\n  # - Check redmine database to see if the user exists\n  #   - If user doesn't exist, create the user\n  # - Pass the email on the redmine utility:\n  #   - echo \"email contents\" | rake redmine:email:read RAILS_ENV=\"production\" project=myproject\n  \n  use strict;\n  use DBI;\n  # global variables\n  my $DbName = 'redmine';\n  my $DbUser = 'redmine';\n  my $DbPassword = 'Secur3P@ass';\n  my @fields;\n  my @address;\n  my $existinguser;\n  \n  # Get email from stdin\n  my @email = <STDIN>;\n  \n  # Parse field for \"for\"\n  foreach (@email)\n  {\n  \tif ($_ =~ /From/)\n  \t{\n  \t\t@fields = (split /</,$_);\n  \t\t@address = (split />/,$fields[1]);\n  \t}\n  }\n  \n  my $dbh = DBI->connect('dbi:mysql:' . $DbName, $DbUser, $DbPassword, { PrintError => 0 }) or die \"SQL Connect Error:\" . DBI->errstr;\n  \n  # Find out if there're any existing users with the specified email address\n  my $sqlStatement = \"SELECT * from users where mail = '$address[0]';\";\n  \n  my $sqlCommand = $dbh->prepare($sqlStatement);\n  \n  $sqlCommand->execute or die \"SQL Error: \" . DBI->errstr;\n  \n  my @sqlRecordset;\n  $existinguser = 'maybe';\n  \n  @sqlRecordset = $sqlCommand->fetchrow_array;\n  \n  if ($sqlRecordset[0] == '') {\n  \tprintf \"@sqlRecordset \\n\";\n  \t$existinguser = 'no';\n  }\n  else {\n  \t$existinguser = 'yes';\n  }\n  \n  # If there isn't a user already, then create one\n  if ($existinguser == 'no')\n  {\n  \tmy @name = (split /@/,$address[0]);\n  \tprintf \"Current variables: $name[0]  $address[0]  \\n\";\n  \t$sqlStatement = \"INSERT INTO users (login, firstname, lastname, mail, mail_notification, admin, status, language, type) values (\\\"$name[0]\\\", \\\"$name[0]\\\", \\\" \\\", \\\"$address[0]\\\", 0, 0, 1, \\\"en\\\", \\\"User\\\");\";\n  \t$sqlCommand = $dbh->prepare($sqlStatement);\n  \t$sqlCommand->execute or die \"SQL Error: \" .DBI->errstr;\n  \tprintf \"User created\";\n  }\n  \n  my $timeinsec = `date +%s`;\n  open (MYFILE, \">>/var/tmp/$timeinsec\");\n  print MYFILE \"@email\";\n  close (MYFILE);\n  \n  system(\"sed -i 's/^  //' /var/tmp/$timeinsec\");\n  system(\"sed -i 's/^ //' /var/tmp/$timeinsec\");\n  \n  `cd /usr/share/webapps/redmine && rake redmine:email:read RAILS_ENV=\"production\" project=myproject < /var/tmp/$timeinsec`;\n  exit 0\n\nThis document is a Work In Progress.\n\n[[Category:Server]]\n[[Category:Ruby]]\n[[Category:SQL]]\n[[Category:Programming]]\n\n\n=Installing Redmine Since 2.1.2=\n\nRedmine in Alpine has switched from lighttpd to unicorn httpd (ruby-fcgi currently has issues and according to redmine devs its the prefered way to run redmine).\n\nThis basic howto is based on sqlite and has only been tested with sqlite. We need to install the following packages:\n\n {{Cmd|apk add ruby-sqlite ruby-unicorn redmine}}\n\nCopy the sample config file inside /etc/unicorn\n\n {{Cmd|cp /etc/unicorn/redmine.conf.rb.sample /etc/unicorn/redmine.conf.rb}}\n\nEdit unicorn conf.d file and set the config file to /etc/unicorn/redmine.conf.rb\n\n {{Cmd|vim /etc/conf.d/unicorn}}\n\nEdit redmine database config and set sqlite as database\n\n {{Cmd|vim /etc/redmine/database.yml}}\n\nMake sure the database directory exists and change owner to redmine\n\n {{Cmd|cd /usr/share/webapps/redmine}}\n {{Cmd|sudo -u redmine rake generate_secret_token}}\n {{Cmd|sudo -u redmine RAILS_ENV&#x3D;production rake db:migrate}}\n\nMake sure redmine.conf.rb is correct and run:\n\n {{Cmd|rc-service unicorn start}}\n\nThis will start unicorn httpd and listens on 0.0.0.0:8080 by default.\n\nUnicorn is a very basic httpd it is advised to use a reverse proxy in front of it like nginx, pound or any other reverse proxy.\n\nInstall additional plugins\n\n*Copy the plugin directory into the vendor/plugins directory.\n\n*Do migration task. (e.g. rake db:migrate_plugins RAILS_ENV=production)\n\n*(Re)Start Unicorn.\n\nMake sure that the plugin is compatible with your redmine. Installation procedure may vary depending on the plugin."
                    }
                ]
            },
            "2354": {
                "pageid": 2354,
                "ns": 0,
                "title": "Regex",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "This page summarizes some gritty regex details. It's not intended as a tutorial on any of these regex languages, but rather as a technical summary and list of \"gotchas\" (places where different implementations of a tool may behave in different or unexpected ways).\n\n{{Warning|This summary was drawn up back when we were using uClibc. Some of the behavior of Alpine's utilities reported here may have changed with the switch to musl.}}\n\n__TOC__\n\n== Glob patterns == \n\nThese are used in shell expansion and pattern-matching in <code>case</code> expressions.\n\n# <code>glob*</code>\n# <code>gl?bbing</code>\n# <code>[a-z]</code> and <code>[!-aeiou]</code>\n\n<code>[!-aeiou]</code> can also be expressed in some shells (including BusyBox <code>ash</code>) as <code>[^-aeiou]</code> but the <code>[!...]</code> format is more portable.\n\n<ul>\n\n<li>If the pattern contains an invalid bracket expression or does not match any existing filenames or pathnames, the pattern string will be interpreted literally.\n\n<li>A leading period can only be matched literally, not by <code>[!a]</code> or <code>?</code> or <code>*</code> or <code>[%-0]</code> or <code>&#91;&#91;:punct:]]</code>. In BusyBox ash, it's not matched by <code>[.a]</code>; other shell implementations may differ.\n\n<li><code>/</code> can only be matched literally, and has higher parsing precedence than <code>[...]</code>, so <code>a[b/c]d</code> only matches file {{Path|c]d}} in directory {{Path|a[b}}.\n\n<li>Given the pattern <code>/foo/bar/x*/bam</code>, search permission is needed for directories {{Path|/}} and {{Path|foo}}, search and read permissions are needed for directory {{Path|bar}}, and search permission is needed for each {{Path|x*}} directory.\n\n<li>If <code>set -f</code> / <code>set -o noglob</code>, glob-expansion is disabled.\n\n{{Todo|What contexts automatically suppress glob-expansion?}}\n\n<!--\nBash has the options:\n* shopt -s extglob: \"extended globbing\"\n   ?(pat|pat) Matches zero or one occurrence of the given patterns\n   *(pat|pat) Matches zero or more occurrences of the given patterns\n   +(pat|pat) Matches one or more occurrences of the given patterns\n   @(pat|pat) Matches one of the given patterns\n   !(pat|pat) Matches anything except one of the given patterns\n* shopt -s nullglob: non-matching globs are removed, rather than preserved literally\n* shopt -s failglob: non-matching globs produce an error message and the current command is not executed \n* shopt -s dotglob: match . at start of pathname or immediately following /\n* shopt -s nocaseglob: glob-expansion performed case-insensitively\n* shopt -s globstar: recursively match all files and directories below curdir; you can't limit the match with **.c or such, but you can do **/*.c\n-->\n</ul>\n\n'''Q.''' How do I construct a shell glob-pattern that matches all files except \".\" and \"..\" ? (from [http://www.faqs.org/faqs/unix-faq/faq/ Unix FAQ] 2.11)\n<!--\n      You could employ an external program or two and use backquote substitution.  This is pretty good:\n          `ls -a | sed -e '/^\\.$/d' -e '/^\\.\\.$/d'`\n      or `ls -A` in some Unix versions, including BusyBox's ls, but even these will mess up on files with newlines, IFS characters or wildcards in their names.\n-->\n\n{|\n! width=200px | Pattern\n! matches {{Path|.}} ? !! matches {{Path|..}} ? !! matches {{Path|.a}} ? !! matches {{Path|.ab}} ? !! matches {{Path|..pdq}} ? !! matches {{Path|xyz}} ?\n|-\n! <code>*</code>\n| no || no || no || no || no || yes\n|-\n! <code>.*</code>\n| yes || yes || yes || yes || yes || no\n|-\n! <code>.[!.]*</code>\n| no || no || yes || yes || no || no\n|-\n! <code>.??*</code>\n| no || no || no || yes || yes || no\n|}\n\nHence, to match all of the four rightmost columns, but neither of the two leftmost ones, you need to combine three glob patterns: <code>* .[!.]* .??*</code>\n\nIf you don't have any length-2 filenames like {{Path|.a}}, you can go with the simpler: <code>* .??*</code>\n\n== POSIX regex ==\n\nPOSIX defines two classes of regex languages: '''basic regular expressions (BREs)''' and '''extended regular expressions (EREs)'''. The first is historically implemented by utilities like <code>grep</code>, <code>sed</code>, and <code>ed</code>. The second by tools like <code>egrep</code> (<code>grep -E</code>), <code>[[awk]]</code>, <code>lex</code>, and <code>emacs</code>. EREs are usually also available as an option to <code>sed</code>; sometimes this is expressed using <code>sed -r</code>, other times <code>sed -E</code>. (BusyBox <code>sed</code> uses the first.)\n\nIn practice most implementations of these regex languages go beyond the specification, for example including Gnu extensions like <code>\\w</code>, or including features that were only historically available (and are only specified for) the other regex language: thus most implementations of BREs will also honor <code>\\+</code> and <code>\\|</code>, and many implementations of EREs will also honor backreferences like <code>\\1</code>. Additionally, <code>awk</code> EREs obeys somewhat different rules than other EREs.\n\n{{Note|Historically, BRE-using regex engines are implemented using [https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton NFAs] or \"pattern-directed\" regex engines. EREs were often implemented using more efficient [https://en.wikipedia.org/wiki/Deterministic_finite_automaton DFAs] or \"text-directed\" regex engines. There are theoretical translations between these, but in practice devices like backreferences and non-greedy quantification can only be efficiently implemented with NFAs---so although DFAs are faster, they are also more limited.\n\nOne difference between naive implementations of these is that NFAs are more \"eager.\" Both types of engines will return the leftmost of several possible matches ''in the source text''; but the greater eagerness of a NFA would show up in which of several ''alternative patterns'' it used to do the matching. For any regex engine which can handle alternative patterns, <code>printf \"NFA, no I mean DFA\" {{!}} regex_match \"/NFA{{!}}NFA, no I mean DFA/\"</code> would match the whole source text if the engine were a DFA; but would match only \"NFA\", using the left pattern, if the engine were a (naive) NFA.\n\nHowever, this is nowadays complicated by the fact that POSIX specifies the ''longest'' possible leftmost stretch of source text be matched: so a POSIX-conformant <code>grep</code> (which accepted pattern alternation as an extension) would have to match \"NFA, no I mean DFA\", too, just as <code>egrep</code> would.\n\nIt's also complicated by the fact that many ERE engines nowadays will honor backreferences, which can't efficiently be matched with DFA/\"text-directed\" techniques.}}\n\n\nPOSIX specifies for both BREs and EREs:\n\n* matches should be longest match leftmost in text\n* subpatterns match greedily (with matching the empty string \"\" better than not matching)\n* nulls (\\0) are not permitted in text nor in patterns\n\nFor the following, I've compared the BusyBox tools (<code>grep</code>, <code>egrep</code>, <code>sed</code> with and without <code>-r</code>, and <code>awk</code>) to the Gnu core tools, and to the versions of these tools in a base FreeBSD 9 system. I refer to the Gnu implementation of <code>awk</code> as \"gawk\" (as Gnu itself does); and I refer to the FreeBSD implementation of <code>awk</code> as \"nawk\" (though properly speaking, this is just one among several implementations of nawk).\n\n\n=== BREs ===\n{{Draft|}}\n\n<div style=\"white-space:pre; font-family:monospace;\"><nowiki>\nSpecial characters: . * [] ^ $ \\(\\) \\{\\}\n    \nDot and [^x] should match newline; but on no grep -z implementation do they do so.\n\nAnchors ^ $\n    POSIX says interpreted literally when not at start of pattern/group/alternate (FreeBSD grep is buggy with ^)\n    All [e]greps match start-of-lines and end-of-lines even with multiline buffers (though FreeBSD's [e]grep -o ^... is buggy)\n    Sed engines, on the other hand, only ever match these anchors against start-of-buffer and end-of-buffer.\n\nAlternation with \\|\n    Not in POSIX for BREs, but is honored by many <code>grep</code>s and <code>sed</code>s\n    FreeBSD tools don't handle \\| in these contexts: \"_ ... | _ ... ( _ ... _ ) ... _\"\n\nIntervals \\{m,n\\}\n    \\? for \\{0,1\\} and \\+ for \\{1,\\} aren't in POSIX, but are often honored.\n    All greps and and all seds except FreeBSD's do support \\| \\? \\+ and other Gnu extensions\n    Unmatched \\{ rejected as error\n    Unmatched \\} usually treated as literal; only FreeBSD sed without -r rejects\n    Gnu sed accepts \\{,1\\}; others reject and all reject \\{\\}, \\{2,1\\}, and \\{1,2,3\\}\n\nPerversely-placed quantifiers\n    Treated as literals at start of a pattern/group/alternate (after ^, if any)\n    This is true for *, \\?, and \\+ where they're available\n    But \\{1\\} is instead rejected as an error by FreeBSD and Gnu sed\n\n    FreeBSD and Gnu grep, BusyBox grep and sed: accept adjacent quantifiers without error\n        Gnu and FreeBSD sed: reject \\{...\\} and * when they follow another quantifier\n        Gnu sed: permits \\? and \\+ to do so; FreeBSD doesn't recognize them as quantifiers\n\nGroups \\( \\) and backreferences \\1-\\9\n    ^\\(ab*\\)*\\1$ matches ababbabb but not ababbab (backref to last match of the antecedent pattern)\n        unmatched \\( or \\) rejected as error\n\n\\<var>c</var>\n     POSIX doesn't define the behavior of this for orinary characters <var>c</var>. All of the implementations I \n     checked interpret it as matching a literal <var>c</var>.\n\nBracket expressions [...]\n    inside brackets, ^ is literal except at start, and .*[\\ are all literal\n    The following are all required by POSIX (''except in italics''):\n    ] in []...] and [^]...] treated as literal\n    - in [-...] and [^-...] and [...-] treated as literal\n        so [b\\-a] is the set of b,\\,],^,_,`,a; not the set of b,-,a\n    \\ in [...\\...] treated as literal\n        so [a\\]b] is [a\\] then literal b]; not the set of a,],b\n    [:<var>classes</var>:]\n        [:alpha:] [:alnum:] [:upper:] [:lower:]\n        [:xdigit:] [:digit:] but not \\d\n        [:punct:]\n        [:graph:] visible chars except space\n        [:blank:] space or tab\n        [:space:] space or tab or \\n \\r \\v \\f\n        [:print:] visible chars plus space\n        [:cntrl:] ASCII < 32 or 127\n    unmatched [ ''rejected as error''\n    unmatched ] treated as literal\n    [m-ax] ''BusyBox [e]grep and nawk treat as just x, others reject''\n    [a-m-xy] ''BusyBox [e]grep and nawk treat as [a-my], others reject''\n</nowiki></div>\n\n=== EREs ===\n{{Draft|}}\n\n<div style=\"white-space:pre; font-family:monospace;\"><nowiki>\n    . * ? + [] ^ $ | () {}\n    POSIX requires \"long|longest\" should match all of \"longest\", so implementations must at least simulate DFAs in that way\n    dot and [^x] should match newline; but on no egrep -z implementation do they do so\n    ^ $ are always anchors\n        all [e]greps match start-of-lines and end-of-lines even with multiline buffers (though FreeBSD's [e]grep -o ^... is buggy)\n        sed and awk engines only match these anchors against start-of-buffer and end-of-buffer\n        so \".^b\" should match last two chars of $'a\\nb' in grep (if only dot matched newline there), but not in sed; this is what we observe, except that while Gnu sed and gawk will only match '^pat' against start-of-buffer, they match '.^pat' against start-of-line (same with 'pat$.'); also, nawk rejects '.^b' but not 'a$.'\n    |\n        FreeBSD sed and nawk reject | in these contexts: \"_ ... | _ ... ( _ ... _ ) ... _\"; FreeBSD egrep silently fails to match\n    {m,n}\n        nawk and gawk --traditional treat as literal\n        BusyBox and gawk --re-interval handle (this is default for some versions of gawk)\n        unmatched {: BusyBox tools, Gnu sed and gawk reject as error; FreeBSD tools and Gnu egrep treat as literal\n        unmatched }: treated as literal (only FreeBSD sed without -r rejects)\n        Gnu sed and gawk accept {,1}; others reject and all reject {}, {2,1}, and {1,2,3}; except FreeBSD egrep handles the third strangely, and FreeBSD sed treats the first as literal\n    quantifiers at start of pattern/group/alternate (after ^, if any): egreps silently drop (BusyBox whole construct, others only first char); seds with -r and awks usually reject (though gawk treats such quantifiers and any preceding ^ as literal; nawk accepts ^* ^+ ^? but hard to tell what they match)\n    BusyBox and Gnu egrep and sed and awk, FreeBSD egrep and nawk: accept adjacent quantifiers without error; FreeBSD sed rejects all\n\n    ( )\n        all my implementations of egrep provide backrefs (so with those patterns, not running a DFA)\n        ^(ab*)*\\1$ matches ababbabb but not ababbab (backref to last match of the antecedent pattern)\n        FreeBSD sed with -r: \\1 is literal \"1\" rather than backref; other seds provided backrefs\n        awks: \\1 is \\x01 rather than backref\n        unmatched (: rejected as error\n        unmatched ): rejected as error, except FreeBSD and BusyBox sed with -r, and BusyBox awk and gawk, treat as literal\n    \\ordinary undefined (all my egrep and sed implementations treat as literal; awks honor C escapes but will otherwise treat as literal, perhaps with warning)\n\n    inside brackets, ^ is literal except at start, and .*[\\?+|$ are all literal\n    otherwise, as for BREs\n\n    In gawk and nawk, [a\\]1] matches a,],1. In BusyBox awk and egrep/sed, it matches a,\\ followed by literal 1 then ].\n</nowiki></div>\n\n=== Gnu extensions ===\n\nThese were present in all the [e]greps I tested with, and in all the seds and awks except <code>nawk</code> (and <code>gawk --traditional</code>). They are only treated specially outside of bracket expressions, even in awks, which do still treat <code>\\t</code> and so on specially there.\n\n# '''<code>\\w</code>''' and '''<code>\\W</code>''' for <code>[[:alnum:]_]</code> and <code>[^[:alnum:]_]</code>\n# '''<code>\\s</code>''' and '''<code>\\S</code>''' for <code>&#91;&#91;:space:]]</code> and <code>[^[:space:]]</code>, matches any of: space tab \\n \\r \\v \\f\n#: (BusyBox tools and some versions of <code>gawk</code> lack.)\n# '''<code>\\b \\B \\&lt;</code>''' and '''<code>\\&gt;</code>''', zero-width matches at word boundaries (''non''-word-boundaries for <code>\\B</code>)\n#: (In awks, <code>\\b</code> instead means \"\\x08\"; <code>\\y</code> substitutes for <code>\\b</code> in <code>gawk</code>, nothing substitutes for <code>\\b</code> in BusyBox awk.)\n#: <span style=\"color:gray\">FreeBSD's <code>[e]grep -o \\b...</code> and <code>[e]grep -o \\<...</code> are currently buggy; and BusyBox's sed and awk are buggy with <code>\\< \\b \\B</code> at start of words.</span>\n# '''<code>\\` \\'</code>''' start-of-buffer and end-of-buffer anchors (some regex engines not surveyed here use <code>\\A \\Z \\z</code> for these instead)\n#: (In awks, <code>^</code> and <code>$</code> already have this behavior, even against source texts containing newlines.)\n#: <span style=\"color:gray\">FreeBSD's <code>[e]grep</code> currently wrongly match these against start-of-line and end-of-line, rather than start-of-buffer and end-of-buffer. Also, FreeBSD's <code>grep -o '\\`...'</code> is buggy in ways <code>grep -o '...'\\'</code> isn't. BusyBox sed and awk are also buggy with <code>\\`</code> in ways they aren't with <code>\\'</code>. All these bugs have been reported.</span>\n\n=== C escapes ===\n\n; <code>\\n \\t \\r \\x09 \\f \\v \\a \\c</code>\n: These are handled specially by awks (though <code>nawk</code> only honors up to <code>\\f</code>), even inside brackets.\n: They are also handled specially by Gnu's sed. BusyBox's sed honors <code>\\n \\t \\r</code>; and FreeBSD's sed honors <code>\\n</code>. The other escapes aren't honored by those seds, and none are honored by any grep I tested.\n\nThese escapes may also be handled specially by your shell in <code>$'...'</code> constructs; as too may be <code>\\OOO</code> (up to 3 octal digits) <code>\\uXXXX</code> (4 hex digits) <code>\\e \\E \\b \\'</code>. Awk engines handle some of these latter forms, too. As noted [[#Gnu_extensions|above]], the last two are handled differently by some regex engines.\n\n=== Notes ===\n\n* All of these regex engines treat <code>\\d</code> as literal \"d\", not as <code>&#91;&#91;:digit:]]</code>.\n\n* BusyBox sed will match only one occurrence of \"\" (empty string); others will match several of them if the <code>/g</code> modifier is on.\n\n* Grep engines will treat newlines ''in patterns'' as equivalent to <code>\\|</code>; sed and awk engines will reject as error.\n\n* FreeBSD's sed will force the presence of terminal <code>\\n</code>, even if it wasn't present in the input. So too will some other FreeBSD tools like <code>cut</code>; others like <code>tr</code> won't. In Gnu's sed, the command <code>q</code> also forces a terminal <code>\\n</code>.\n\n* BusyBox's <code>grep -oz</code> suffixes each result with \"\\0\" (nul); other greps suffix with <code>\\n</code>.\n\n* Nongreedy quantifiers <code><var>pat</var>?? <var>pat</var>*? <var>pat</var>+? <var>pat</var>{m,n}?</code> aren't provided in the POSIX specification, nor by any of the POSIX-conforming tools discussed here.\n\n* FreeBSD grep and egrep match the empty string at position 0 in: <code>printf 'cba' | egrep -o '[ba]*'</code>. None of the other [e]grep implementations I checked (such as BusyBox's or Gnu's) do this.\n\n== Regex in Lua ==\n\n=== String escapes ===\n\nIn Lua, regex patterns are always supplied as strings, so will honor all the normal escapes on strings:\n\n \\\\\n \\\"\n \\'\n \\a for bell, \\x07\n \\b for backspace, \\x08\n \\t for \\x09\n \\n for \\x0a\n \\v for \\x0b\n \\f for \\x0c\n \\r for \\x0d\n\nLua strings also accept <code>\\<var>ddd</var></code> for ''decimal'' digits <var>d</var>. ('''Note:'''  ''not'' octal digits.) Starting with Lua 5.2, <code>\\x<var>hh</var></code> for hex digits is also accepted.\n\nStrings can be written inside matching single or double quotes. They can also be written inside:\n\n [[constructs\n like this]]\n \n [=[\n or &#91;&#91;like]]\n \\this]=]\n\nIn these constructs, escape sequences like <code>\\t</code> aren't expanded. It and the embedded <code><nowiki>[[like]]</nowiki></code> are both treated literally. Also, the first character of the string is ignored when it's a newline.\n\n=== Regex engines ===\n\nThe basic Lua regex engine is more limited than the Posix- or PCRE-style languages, though still quite capable. In fact some things are more easily done with the Lua engine than with the more familiar ones. If the basic Lua engine is nonetheless too limited for your purposes, you should look into the [https://www.inf.puc-rio.br/~roberto/lpeg/ LPEG] or [https://github.com/rrthomas/lrexlib Lrexlib] libraries. The former is more powerful and widely-used in the Lua community; the latter interfaces to more familiar regex engine libraries and languages.\n\n=== Regex specials ===\n\nThe following sequences have special meaning to the basic Lua regex engine.\n\n<dl>\n<dt>Character classes\n<dd>\n '''.'''            Matches any character\n <br />\n '''%z'''           In Lua 5.1, the regex engine wouldn't read past an embedded \\0 in the pattern string, so this special sequence\n              was provided instead to match \\0s in the source text (and permit the pattern string to continue).\n              In Lua 5.2, embedded '''\\0'''s can now be used directly. With the default compilation settings, %z is still honored,\n              but it's deprecated.\n <br />\n '''%a''' and '''%A'''    Like POSIX &#91;&#91;:alpha:]] and [^[:alpha:]]\n '''%l''' and '''%L'''    Like POSIX &#91;&#91;:lower:]] and [^[:lower:]]\n '''%u''' and '''%U'''    Like POSIX &#91;&#91;:upper:]] and [^[:upper:]]\n <br />\n '''%w''' and '''%W'''    Like POSIX &#91;&#91;:alnum:]] and [^[:alnum:]].\n              (Note that ''unlike'' the Gnu regex extension <code>\\w</code>, the patterns <code>%w</code> in Lua and <code>&#91;&#91;:alnum:]]</code> in POSIX do ''not'' match underscores.)\n '''%d''' and '''%D'''    Like POSIX &#91;&#91;:digit:]] and [^[:digit:]]\n '''%x''' and '''%X'''    Like POSIX &#91;&#91;:xdigit:]] and [^[:xdigit:]]\n <br />\n '''%s''' and '''%S'''    Like POSIX &#91;&#91;:space:]] and [^[:space:]].\n              (%s and POSIX &#91;&#91;:space:]] do also match vertical space (\\n \\r \\f \\v, whereas POSIX &#91;&#91;:blank:]] matches only \\x20 and tab.)\n '''%p''' and '''%P'''    Like POSIX &#91;&#91;:punct:]] and [^[:punct:]], excludes space and alnum and cntrl\n '''%c''' and '''%C'''    Like POSIX &#91;&#91;:cntrl:]] and [^[:cntrl:]]\n '''%g''' and '''%G'''    Like POSIX &#91;&#91;:graph:]] and [^[:graph:]], all visible characters except space; only so interpreted in Lua 5.2\n\nPOSIX <code>&#91;&#91;:print:]]</code>, all visible characters plus space, isn't directly available. Use <code>[%p%w ]</code> or <code>[%g ]</code>.\n\n<dt>Bracket expressions\n<dd>'''[<var>class</var>]''' and '''[^<var>class</var>]''' can include sequences of:\n* single characters like <code>a</code> or <code>\\t</code>\n* ranges like <code>a-m</code>\n* character class specials like <code>%a</code> \n \n<dt>Groups and backreferences\n<dd>\n* '''<code>(<var>pat</var>)</code>'''  Capture the source text matching <var>pat</var> into a group. Unlike other regex engines, these constructions can ''not'' be followed by quantifiers like <code>*</code> or <code>+</code>\n* '''<code>%1</code>'''  Backreference to a captured group (contrast <code>\\1</code> which is and matches \"\\x01\", and <code>\\\\1</code> which matches a literal character \"\\\" then \"1\")\n* '''<code>()</code>'''  Instead of text, capture the current position in the matched source into a group\n\n<dt>Quantifiers \n<dd>\n* '''<code>?</code>''' and '''<code>*</code>''' and '''<code>+</code>''' are the familiar greedy quantifiers\n* '''<code>-</code>''' is a nongreedy variant of <code>*</code>\n\nNote that in Lua quantifiers can only follow:\n* single characters\n* regex specials like <code>.</code> and <code>%a</code>\n* <code>[<var>class</var>]</code> expressions\nThey ''cannot'' follow arbitrary <code>(<var>pat</var>)</code>\n\n<dt>Anchors ^ $\n<dd>As in POSIX BREs, these are treated as literal characters when not in anchoring positions (as in the pattern <code>ab^cd</code>)\n\n<dt>Literal characters\n<dd>'''%<var>c</var>''' This is a literal <var>c</var>, for arbitrary character <var>c</var>. It cancels the special meaning of characters <code>( ) . % + - * ? [ ] ^ $</code>\n</dl>\n\n\n'''Alternation''' (expressed in other regex languages using <code>|</code>)\nis not available in Lua; it can only be approximated using <code>[<var>class</var>]</code> constructions.\n\nTwo of the nifty primitives that Lua has and other engines lack are:\n\n<ul>\n<li>'''<code>%b()</code>'''         Text inside (and including) balanced <code>(...)</code>; other characters can be used in place of <code>(</code> and <code>)</code>.\n<li>'''<code>%f[<var>class</var>]</code>'''    The zero-width \"frontier\" between (the start-of-source or) text not matching <var>class</var> and (the end-of-source or) text which does match <var>class</var>. This is a generalization of the Gnu regex specials <code>\\&lt;</code> and <code>\\&gt;</code>. Examples:\n<pre>\n%f[%x] matches the source text \"123-567 9ab\" before positions 1, 5, and 9\n%f[%X] matches the same source text before positions 4, 8, and 12.\n</pre>\n</ul>\n\n\n[[Category:Shell]] [[Category:Lua]]"
                    }
                ]
            }
        }
    }
}