Posts Tagged ‘regular-expressions’

How to ease editing work in MS-Word by automating search/replace operations

  1. If you frequently have to edit documents according to a large number of editorial rules and regulations
  2. and if you can partially automate these edit operations  (or at least highlight suspicious passages for human review) with Word’s search/replace,
  3. I can recommend an add-in that can automate even the repeated search/replace operations (like the 57 in the video below)
  4. and even help you manage your search/replace strings and regular expressions in a spreadsheet which it can load from:
  5. Greg Maxey’s VBA Find & Replace Word Add-in. See it in action (click for full size):
  6. vbareplace
  7. Two Three Caveats: :
    1. At this point, I cannot get the add-in to work only in Word 2010. Even if I lower Macro security and allow programmatic access to the VBA project, when trying to launch the add-in from the ribbon, Word 2013 complains: “The macro cannot be found or has been disabled due to your macro security settings”:image.
    2. The automation is only as good as your underlying search/replace operations. (Hint: “Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems.”)
    3. I think I will refrain from search/replace during “Tracking changes” – as in the video – , and rather use “Compare documents” after the replace operations – too many quirks otherwise…

Source code samples

How to identify graded participants in Moodle Course Activity Reports using Vlookup

  1. Having a chart of full names, Moodle id # and usernames would be useful (e.g. for debugging with the Activity Reports that in some cases do not resolve Moodle id# so Excel vlookup has to rescue the day once again…)
  2. The Moodle “Participants” affords the instructor a convenient list, with paging, sort, filter (by role), and different detail-level views.
  3. However, the overview does link course and student id #, but not institutional username while the detail view contain the username as part of the email, but is not truly tabular (consists of an array of tables, each containing one user; at least you can avoid the paging).
  4. Enter grepwin to extract the emails:


  5. and copy paste them into the Excel created from the tabular overview:
  6. lookupIs there an easier way?

Tools for Search-Replace text with Regular Expression on Windows

Just a quick thumbs up for a free tool:

To examine licensing files, I am looking for a tool that can massage the computer-readable file (no XML) into a friendlier format (that can be imported into Excel).

The regular needed to achieve that I too complex for TextPad or MS-Word.

Other tools I have used have not been updated in a long ime (RegEx Workbench).

Grep for Windows? I have just revitalized my cygwin installation, but would like something a little more user-friendly, with a GUI .

That also rules out PowerShell’s 2.0 Select-String.

PowerGrep, as recommended on stackoverflow, looks nice, but is not free.

inforapid-searchreplacer looks not bad, but I went for grepWin, which got the job done quickly and nicely:

Click Button “Test” to preview results:


Click Button “Search” to file the matching files list:


Limitations of GrepWin: Is there a size limit in the test regex text input field – here is how my test text got truncated:


Building interactive exercises for language learning on subtitle corpora

Using home-brew NLP regular expressions to automate question generation for learning material creation

    1. The trpQuizGenerator, from which the screenshots below are taken,
      1. is an attempt to facilitate, speed up, automate question generation for foreign language learning by collecting a regular expressions, reflecting typical patterns that cause difficulties for language learners in a number of L2 – inspired by common 1st and 2nd year textbooks:  trpQuizGenerator-NLP-samples-German-Italian-Spanish
      2. German: differentiation between Dative and Accusative case personal pronouns
      3. Italian: contraction of article and preposition
      4. Spanish: demonstrative pronouns.
      5. Some more rather arbitrary, but easily implemementable examples for ESL:
        1. Numbers: ―Much/many‖ dichotomy
        2. which/who‖ relative pronoun dichotomy: Difficult for German students of English which has no such
          dichotomy for innate beings/things, but whose (antiquated) relative pronoun ―Welch‖ as a false friend
          of which tends to lead to a wrong preference of ―which‖ to ―who‖ by German speakers.
        3. Sub clauses/tenses: if clauses up to period/comma, giving the number of words as hints. Would
          require a delegate.
      6. Regular expressions in .Net have a number of advanced features that makes the platform a good choice for this enterprise: trpQuizGenerator-NLP-sample-German-personalpronomen-akk-dat
      7. The resulting texts can be e.g. easily delivered as formative assessment exercises  to students using
    2. Update:
      1. In a  much more recent approach to the same automation problem, I am trying to repurpose well-established existing NLP-platforms for question generation.
      2. However, compared with the above customized approach, to transform the built-in, not SLA-specific NLP recognition I have found so far taking not only much more work for reformatting for delivery, but also more creativity, or willingness to put up with limitations when it comes to homing in on typical learner problems.