# HG changeset patch # User Christian Urban # Date 1352851358 0 # Node ID 68d664c204d2e3d6d5b85f56ab25595af8a02f1f # Parent b64e876832cc7ee06c45d5229773ec376fa97e6c updated diff -r b64e876832cc -r 68d664c204d2 hw07.pdf Binary file hw07.pdf has changed diff -r b64e876832cc -r 68d664c204d2 hw07.tex --- a/hw07.tex Sun Nov 11 17:28:11 2012 +0000 +++ b/hw07.tex Wed Nov 14 00:02:38 2012 +0000 @@ -57,7 +57,14 @@ \texttt{The trainer trains the student team} \end{center} +\item {\bf (Optional)} The task is to match strings where the letters are in alphabetical order---for example, +\texttt{abcfjz} would pass, but \texttt{acb} would not. Whitespace should be ignored---for example +\texttt{ab c d} should pass. The point is to try to get the regular expression as short as possible! +See: +\begin{center} +\url{http://callumacrae.github.com/regex-tuesday/challenge11.html} +\end{center} \end{enumerate} \end{document} diff -r b64e876832cc -r 68d664c204d2 re-internal.rb --- a/re-internal.rb Sun Nov 11 17:28:11 2012 +0000 +++ b/re-internal.rb Wed Nov 14 00:02:38 2012 +0000 @@ -11,11 +11,12 @@ #create a new regular expression based on current value of i re = Regexp.new(/((a?){#{i}})(a{#{i}})/) - if re.match(string) - puts "matched string a * #{i} with regex #{re}" - else - puts "unmatched string a * #{i} with regex #{re}" - end + re.match(string) + #if re.match(string) + # puts "matched string a * #{i} with regex #{re}" + #else + # puts "unmatched string a * #{i} with regex #{re}" + #end - puts "in = #{(Time.now - start_time) * 1000} milliseconds" + puts "#{i} %.5f" % (Time.now - start_time) end diff -r b64e876832cc -r 68d664c204d2 topics.pdf Binary file topics.pdf has changed diff -r b64e876832cc -r 68d664c204d2 topics.tex --- a/topics.tex Sun Nov 11 17:28:11 2012 +0000 +++ b/topics.tex Wed Nov 14 00:02:38 2012 +0000 @@ -17,19 +17,20 @@ \begin{itemize} \item What is a language? -\item concatenation of two sets of string +\item concatenation of two sets of strings \item power of a set of strings \end{itemize} \section{Regular Expressions} \begin{itemize} +\item definition of regular expressions \item What is the language of a regular expression? \item When are two regular expressions are equal? \item {\it nullable}, {\it der}, {\it zeroable}, {\it rev} \item induction principle of regular expressions \item tokens, maximal munch rule -\item ``negative'' regular expression +\item regular expression for complement language \item tokenisation \end{itemize}