At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I believe regular expressions originate out of early CS theory. I've seen it as an element of set theory in the application of strings as sets. Otherwise the application of string based pattern matching was established with search tools like ed and ultimately grep.
i just wrote random date, would it help if it was correct answer?
Maybe a regex answer would be more apt,1[0-9][0-9].
That last answer gave me a question: how should I write regular expressions? Should I make them as compact as possible while completely expressing what I am looking for, or should I just do what Tomas.A just did and have them be very long, yet still expressing what I am looking for? Suppose I want to grep gaddafi's name. As you may know, there are dozens of different spellings of his name, so I need to use a regex. Should I go for something compact like [QqGg]h?ad+h*afi (don't know if it is correct), or should I go for ([Gg]addafi | [Qq]addafi | [Gg]haddafi | [Qq]adhafi | ...), a big long expression containing all his names?
you should go for shorter one because it was made for computer scientists to shorten everything and it's exactly same, however theoreticians use longer ones but it's actually more simpler because you have to define just a few rules
I would say it depends on the scope of the regex. Sometimes you need very specific matches and sometimes you need very wide abstractions for strings. For instance if you were writing a spell checking application you may want to match a few known examples. However if you were an analytical engine mining data from many sources you would want to have a generic abstraction that would return for all possible misspellings.
no you should always go for shorter one IF it's possible to make one. I don't see any reason why would you want to write 1(8|9)(0|1|2|3|4|5|6|7|8|9)(0|1|2|3|4|5|6|7|8|9) instead of just 1[8-9][0-9][0-9] if it's allowed
agdgdgdgwngo, write the RE so it makes sense to you first. RE's are so efficient and machines are so fast that unless you're searching a huge dataset, the efficiency of running a concise RE won't offset the difficulty of writing it. One thing wrong with your "Quaddafi" REs: as wrtten, they match various forms of " Quaddafi ". Spaces are part of the match, too!