<p>Here's a basic regex technique that I've never managed to remember. Let's say I'm using a fairly generic regex implementation (e.g., grep or grep -E). If I were to do a list of files and match any that end in either <code>.sty</code> or <code>.cls</code>, how would I do that?</p>

[{'answer_id': 38994, 'author': 'Peter Hoffmann', 'author_id': 720, 'author_profile': 'https://Stackoverflow.com/users/720', 'pm_score': 2, 'selected': False, 'text': '<pre><code>egrep "\\.sty$|\\.cls$"\n</code></pre>\n'}, {'answer_id': 39000, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 2, 'selected': False, 'text': '<p>This regex:<br>\n    \\.(sty|cls)\\z<br>\nwill match any string ends with .sty or .cls<br>\n<strong>EDIT:</strong><br>\nfor grep \\z should be replaced with $ i.e.\n    \\.(sty|cls)$\nas <a href="https://stackoverflow.com/questions/38993/regex-to-match-unique-substrings#38995">jelovirt</a> suggested.</p>\n'}, {'answer_id': 39004, 'author': 'David Webb', 'author_id': 3171, 'author_profile': 'https://Stackoverflow.com/users/3171', 'pm_score': 3, 'selected': True, 'text': '<pre><code>ls | grep -E "\\.(sty|cls)$"\n</code></pre>\n\n<ul>\n<li><code>\\.</code> matches literally a <code>"."</code> - an unescaped <code>.</code> matches any character</li>\n<li><code>(sty|cls)</code> - match <code>"sty"</code> or <code>"cls"</code> - the | is an <code>or</code> and the brackets limit the expression.</li>\n<li><code>$</code> forces the match to be at the end of the line</li>\n</ul>\n\n<p>Note, you want <code>grep -E</code> or <code>egrep</code>, not <code>grep -e</code> as that\'s a different option for lists of patterns.</p>\n'}]
['https://Stackoverflow.com/questions/38993', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4161/']