<p>I have worked for 5 years mainly in java desktop applications accessing Oracle databases and I have never used regular expressions. Now I enter Stack Overflow and I see a lot of questions about them; I feel like I missed something. </p>

<p>For what do you use regular expressions?</p>

<p>P.S. sorry for my bad english</p>

[{'answer_id': 4959, 'author': 'Matt MacLean', 'author_id': 22, 'author_profile': 'https://Stackoverflow.com/users/22', 'pm_score': 0, 'selected': False, 'text': '<blockquote>\n  <p>A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as <code>*.txt</code> to find all text files in a file manager. The regex equivalent is <code>.*\\.txt$</code>.</p>\n</blockquote>\n\n<p>A great resource for regular expressions: <a href="http://www.regular-expressions.info" rel="nofollow noreferrer">http://www.regular-expressions.info</a></p>\n'}, {'answer_id': 4962, 'author': 'Teifion', 'author_id': 1384652, 'author_profile': 'https://Stackoverflow.com/users/1384652', 'pm_score': 3, 'selected': False, 'text': '<p>Regular Expressions (or Regex) are used to pattern match in strings. You can thus pull out all email addresses from a piece of text because it follows a specific pattern.</p>\n\n<p>In some cases regular expressions are enclosed in forward-slashes and after the second slash are placed options such as case-insensitivity. Here\'s a good one :)</p>\n\n<pre><code>/(bb|[^b]{2})/i\n</code></pre>\n\n<p>Spoken it can read "2 be or not 2 be".</p>\n\n<p>The first part are the (brackets), they are split by the pipe | character which equates to an or statement so (a|b) matches "a" or "b". The first half of the piped area matches "bb". The second half\'s name I don\'t know but it\'s the square brackets, they match anything that is <strong>not</strong> "b", that\'s why there is a roof symbol thingie (technical term) there. The squiggly brackets match a count of the things before them, in this case two characters that are not "b".</p>\n\n<p>After the second / is an "i" which makes it case insensitive. Use of the start and end slashes is environment specific, sometimes you do and sometimes you do not.</p>\n\n<p>Two links that I think you will find handy for this are</p>\n\n<ol>\n<li><a href="http://www.regular-expressions.info/" rel="noreferrer">regular-expressions.info</a></li>\n<li><a href="http://en.wikipedia.org/wiki/Regular_expression" rel="noreferrer">Wikipedia - Regular expression</a></li>\n</ol>\n'}, {'answer_id': 4972, 'author': 'Mike Stone', 'author_id': 122, 'author_profile': 'https://Stackoverflow.com/users/122', 'pm_score': 4, 'selected': True, 'text': '<p>Consider an example in Ruby:</p>\n\n<pre><code>puts "Matched!" unless /\\d{3}-\\d{4}/.match("555-1234").nil?\nputs "Didn\'t match!" if /\\d{3}-\\d{4}/.match("Not phone number").nil?\n</code></pre>\n\n<p>The "/\\d{3}-\\d{4}/" is the regular expression, and as you can see it is a VERY concise way of finding a match in a string.</p>\n\n<p>Furthermore, using groups you can extract information, as such:</p>\n\n<pre><code>match = /([^@]*)@(.*)/.match("myaddress@domain.com")\nname = match[1]\ndomain = match[2]\n</code></pre>\n\n<p>Here, the parenthesis in the regular expression mark a capturing group, so you can see exactly WHAT the data is that you matched, so you can do further processing.</p>\n\n<p>This is just the tip of the iceberg... there are many many different things you can do in a regular expression that makes processing text REALLY easy.</p>\n'}, {'answer_id': 4982, 'author': 'Marcel Levy', 'author_id': 676, 'author_profile': 'https://Stackoverflow.com/users/676', 'pm_score': 0, 'selected': False, 'text': '<p>If you\'re just starting out with regular expressions, I heartily recommend a tool like The Regex Coach:</p>\n\n<p><a href="http://www.weitz.de/regex-coach/" rel="nofollow noreferrer">http://www.weitz.de/regex-coach/</a></p>\n\n<p>also heard good things about RegexBuddy:</p>\n\n<p><a href="http://www.regexbuddy.com/" rel="nofollow noreferrer">http://www.regexbuddy.com/</a></p>\n'}, {'answer_id': 15397, 'author': 'Jon Ericson', 'author_id': 1438, 'author_profile': 'https://Stackoverflow.com/users/1438', 'pm_score': 0, 'selected': False, 'text': '<p>As you may know, Oracle now has regular expressions: <a href="http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/rischert_regexp_pt1.html" rel="nofollow noreferrer">http://www.oracle.com/technology/oramag/webcolumns/2003/techarticles/rischert_regexp_pt1.html</a>.  I have used the new functionality in a few queries, but it hasn\'t been as useful as in other contexts.  The reason, I believe, is that regular expressions are best suited for finding structured data buried within unstructured data.</p>\n\n<p>For instance, I might use a regex to find Oracle messages that are stuffed in log file.  It isn\'t possible to know where the messages are--only what they look like.  So a regex is the best solution to that problem.  When you work with a relational database, the data is usually pre-structured, so a regex doesn\'t shine in that context.</p>\n'}, {'answer_id': 15401, 'author': 'Kibbee', 'author_id': 1862, 'author_profile': 'https://Stackoverflow.com/users/1862', 'pm_score': 2, 'selected': False, 'text': '<p>If you want to learn about regular expressions, I recommend <a href="https://rads.stackoverflow.com/amzn/click/com/0596528124" rel="nofollow noreferrer" rel="nofollow noreferrer">Mastering Regular Expressions</a>.  It goes all the way from the very basic concepts, all the way up to talking about how different engines work underneath.  The last 4 chapters also gives a dedicated chapter to each of PHP, .Net, Perl, and Java. I learned a lot from it, and still use it as a reference.  </p>\n'}, {'answer_id': 25850, 'author': 'Konrad Rudolph', 'author_id': 1968, 'author_profile': 'https://Stackoverflow.com/users/1968', 'pm_score': 3, 'selected': False, 'text': '<p>Coolest regular expression <em>ever</em>:</p>\n\n<pre><code>/^1?$|^(11+?)\\1+$/\n</code></pre>\n\n<p>It tests if a number is prime. And it works!!</p>\n\n<p>N.B.: to make it work, a bit of set-up is needed; the number that we want to test has to be converted into a string of “<code>1</code>”s first, <em>then</em> we can apply the expression to test if the string does <em>not</em> contain a prime number of “<code>1</code>”s:</p>\n\n<pre><code>def is_prime(n)\n  str = "1" * n\n  return str !~ /^1?$|^(11+?)\\1+$/ \nend\n</code></pre>\n\n<p>There’s a detailled and very approachable explanation over at <a href="http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/" rel="nofollow noreferrer">Avinash Meetoo’s blog</a>.</p>\n'}, {'answer_id': 25889, 'author': 'Onorio Catenacci', 'author_id': 2820, 'author_profile': 'https://Stackoverflow.com/users/2820', 'pm_score': 0, 'selected': False, 'text': '<p>These RE\'s are specific to Visual Studio and C++ but I\'ve found them helpful at times:</p>\n\n<p>Find all occurrences of "routineName" with non-default params passed: </p>\n\n<p><em>routineName\\(:a+\\)</em></p>\n\n<p>Conversely to find all occurrences of "routineName" with only defaults:\n   <em>routineName\\(\\)</em></p>\n\n<p>To find code enabled (or disabled) in a debug build:</p>\n\n<p><em>\\#if.</em>_DEBUG*</p>\n\n<p>Note that this will catch all the variants: ifdef, if defined, ifndef, if !defined</p>\n'}, {'answer_id': 1437610, 'author': 'Philippe Leybaert', 'author_id': 113570, 'author_profile': 'https://Stackoverflow.com/users/113570', 'pm_score': 0, 'selected': False, 'text': '<p><strong>Validating strong passwords</strong>:</p>\n\n<p>This one will validate a password with a length of 5 to 10 alphanumerical characters, with at least one upper case, one lower case and one digit:</p>\n\n<pre><code>^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])[a-zA-Z0-9]{5,10}$\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/4954', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/518/']