rod mclaughlin


Software Development by Random Guesswork (14 feb 21)

Using the software development method known as 'random guesswork', I changed a regex, putting the underscore before the dash, instead of the other way round, and found I could correctly turn URLs with dashes after the domain, AND with underscores after the domain, like so:

    /[^\s]{2,}\.[0-9A-Za-z\/\?&=_-]+/

This correctly isolates the following strings, and turns them into URLs with href='http://...' etc.

  www.civitas.org.uk/underscore_articles/the-macpherson-report/

  htttps://www.amazon.com/Difficult-With-Dashes-ebook/dp/B001FA0SPG.



Back
Portland London