# Help me figure out what TeX I can use!

On TeX.SE the Help Centre says that the following is on topic:

Formats like LaTeX, ConTeXt and plain TeX
Engines like pdfTeX, LuaTeX and XeTeX
Distributions like TeX Live, MiKTeX, and MacTeX
Related software and tools, BibTeX, MakeIndex, Lyx, etc.


I wanted you to write a program to tell me whether my TeX is in the on-topic types of TeX.

An explicit list of the valid TeX-s is as follows:

• MetaPost
• PostScript
• MetaFUN
• TeX
• LaTeX
• LuaLaTeX
• LuaTeX
• ConTeXt
• BibTeX
• pdfTeX
• Lyx
• MakeIndex
• TeX Live
• XeLaTeX
• XeTeX
• MacTeX
• MiKTeX

## Rules

• You may use any language.
• This is , to the shortest answer wins.
• If you use Regex, you can just match correct ones.
• You only need to match one at a time: no

Lyx BibTeX

• You must check with capitalization listed here.

## Tests

TeX -> True/1/<match>
pTeX -> False/0/<not-match>
ConTeXt -> True/1/<match>
context -> False/0/<not-match>
MetaFun -> False/0/<not-match>
MetaFUN -> True/1/<match>


P.S. Bonus points for an on-topic TeX answer!

• @closevoter This is a tips question, which is explicitly on-topic. Jul 3 '16 at 20:41
• You also seem to be missing MiKTeX in your full list. Jul 4 '16 at 6:02
• Why not make this a challenge?
– user45941
Jul 4 '16 at 7:17
• @DrGreenEggsandIronMan, it's tagged tips, but it looks far too specific to be a tips question. I agree with Mego that it's really a challenge, but as a challenge it seems to be a moral duplicate of existing "write a regex to match everything in this list" questions. Jul 4 '16 at 7:28
• @DrGreenEggsandIronMan, surely if an existing question's answers answer a new question, that new question is a duplicate, regardless of the tags? The purpose of tags is to help people find similar questions, not to be magical talismen. Jul 4 '16 at 8:43

# JavaScript Regex, 9910199 97 + 1 for g flag = 98 bytes

^(((Xe|Lua)?(La)?|Bib|MiK|pdf|Mac)TeX|ConTeXt|TeX Live|Meta(FUN|Post)|PostScript|MakeIndex|Lyx)$ Test it here. Type into the Text box. Alternatively, test it here. var j =$("#dos");
var text;
function abc(){
text = $('#uno').val(); j.val(text.match(/^(((Xe|Lua)?(La)?|Bib|MiK|pdf|Mac)TeX|ConTeXt|TeX Live|Meta(FUN|Post)|PostScript|MakeIndex|Lyx)$/g) == text ? "Matches!" : "No match!");
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id='uno' /><br />
<button id='tres' onclick="javascript:abc()">Test!</button><br/>
<input id='dos' />

Test all cases:

var j = $("#dos"); var tests = ["TeX", "pTeX", "ConTeXt", "context", "MetaFun", "MetaFUN", "TeX Live"]; function abc(e){ j.val(j.val() + e + ": " + (e.match(/^(((Xe|Lua)?(La)?|Bib|MiK|pdf|Mac)TeX|ConTeXt|TeX Live|Meta(FUN|Post)|PostScript|MakeIndex|Lyx)$/g) == e ? "Matches!" : "No match!") + "\n");
};

function def(){
tests.forEach(abc);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id='tres' onclick="javascript:def()">Test!</button><br/>
<textarea rows=50 cols=200 id='dos'>
</textarea>

• As a code-golf challenge answer, this seems to be invalid as it is not a program or function. Jul 5 '16 at 4:59
• @feersum Except my challenge allows regex. Jul 5 '16 at 16:16
• Is the ^ in the starting and $ at the end of the regular expression really necessary? Jul 6 '16 at 3:41 • @R.Kap Yes. Otherwise pTeX will match. Jul 6 '16 at 3:57 • Ah, I nearly forgot the regex. – user54200 Jul 6 '16 at 14:30 # Perl 5, 103 bytes 102 bytes, plus 1 for -pe instead of e. Stdin→stdout. $_=/^(Meta(Post|FUN)|TeX Live|PostScript|((Xe|Lua)?(La)?|Bib|pdf|M(ac|iK))TeX|ConTeXt|Lyx|MakeIndex)\$/

• How do you output without say/print? Jul 6 '16 at 19:06
• @NoOneIsHere, -p handles reading from stdin and printing to stdout. See perldoc.perl.org/perlrun.html#Command-Switches Jul 6 '16 at 20:46

# Python 3.5, 149147137 136 bytes

import re;lambda f:re.fullmatch('TeX Live|(La|LuaLa|Lua|Bib|pdf|XeLa|Xe|Mac|MiK)?TeX|Lyx|MakeIndex|Meta(Post|FUN)|PostScript|ConTeXt',f)


An anonymous function that uses a regular expression to return a re match object (such as <_sre.SRE_Match object; span=(0, 5), match='LaTeX'>) as a truthy value and None as a falsy value. The actual regular expression is currently 102 100 99 bytes in length.

Try It Online! (Ideone)

• Why if/else? It will still work without the if/else-s because return x == return (1 if x else 0) logically. Jul 6 '16 at 14:35
• @NoOneIsHere I was not sure if I had to, but I was making it so that it returns a truthy/falsy value based on whether a match was found or not. However, if you are fine with a re match object being returned, I'll change it. I just was not sure what kind of output you wanted, so I did this. Jul 6 '16 at 17:44
• According to the Defaults for I/O, if bool(x) == True, then it is allowed. Jul 6 '16 at 17:45
• @NoOneIsHere So it's okay if something like <_sre.SRE_Match object; span=(0, 5), match='LaTeX'> is returned when a match is found? Jul 6 '16 at 17:46
• Yes, as long as bool(x) is True. Jul 6 '16 at 17:47