Tuesday 5 August 2014

developing understanding of how useful the edem626 course was to me

I have been working on the regular expression work with formal languages for the last week. I have been watching my students struggle with the work and what is required. Many became disinterested in this. Last night I went through some of the work I did as part of the EDEM course and using the resources had them use this material, working through the university slides students were able to understand what was happening, what each part did. The questions I was getting at the end of the period showed that students have taken to this, I even included the design of a form that allowed for pattern expression to be run from within the browser rather than using a backend script. This allows for students to develop and test the process straight away.

Need to look at what is expected:

  • Key problem: matching input text
  • Practical application: compilers, web site input fields
  • Algorithm/technique: regular expressions
  • Evaluation: this is required for excellence, and it’s hard to see how to do a reasonable evaluation; however, an in-depth reflection on the design may be suitable if done well
  • Personalised student examples: choice of regular expression to use as an example

What does this code snippet do?…
1
/^[0-9a-zA-Z]+@[0-9a-zA-Z]+[\.]{1}[0-9a-zA-Z]+[\.]?[0-9a-zA-Z]+$/
Those with several years development expertise will realize it’s a regular expression. But even the most astute guru will take a few moments to determine that it checks the validity of an email address. Only a superior subset of that group will comprehend that it’s fairly superficial and won’t check all possibilities.
Regular expressions are extremely powerful search patterns which can be used for string matching and replacement. They’re supported in the majority of languages including JavaScript, PHP, Perl, Java, C#, Python and Ruby.
Individual rules are normally straight-forward, e.g. [a-z] matches a single lowercase character andc.t matches a three letter string starting with ‘c’ and ending with ‘t’ — such as ‘cat’. However, when rules are combined, an indecipherable string of seemingly random codes starts to appear. The one above is relatively simple compared to many you’ll find in the wild.
Creating your own regular expressions is difficult enough and many of us resort to using the force. But it’s easy compared to parsing someone else’s code — which is normally written by someone who has an irrational aversion to comments!
Fortunately, Jeff Avallone has created a solution to your regex woes. RegExper transforms meaningless JavaScript-based expressions into a graphical representation:
Regexper
Admittedly, you’ll still need a reasonable understanding of pattern matching, but it’s far more evident the expression is analyzing an email address.
Behind the scenes, RegExper is a Ruby application which translates regular expressions into an SVG image. The SVG is embedded in the page, but it should be possible to extract or copy it for use in your own documentation.

Also: great slides that describe regex, http://courses.cs.washington.edu/courses/cse154/13sp/lectures/slides/lecture12-regular-expressions.shtml

No comments: