For the longest time, regular expressions have remained something of an enigma to me. Despite the many, many learning opportunities, across various programming languages,  my ignorance of their perplexing syntax usually directed to me toward implementing my own code-based algorithms instead. It’s clear that most of the time, such roll-your-own solutions don’t cut it performance-wise, and probably end up being just as obscure and difficult to decipher, weeks or months down the road.

During my recent endeavor to learn Python, the need for some sprinkles of RegEx quickly presented itself. This time around, I set out to apply myself, and at least master the basics. While clicking around on the web, in search of quality learning resources, I grew pleasantly surprised at the crop of interactive resources on the subject and would like to highlight two for you. They’re a refreshing change from the selection of the many animal-toting books on the matter.

RegexOne.com

Screen Shot 2018-11-30 at 06.43.51

RegexOne.com is a delightful donation-supported website that guides you through the basics of regular expressions with a dozen (or so) lessons which are short, to the point, and each capped with an interactive input box. Exercises build on the previous ones to introduce each subsequent concept, highlighting the current match as you type. The little quizzes aren’t too hard, and in case you get stuck, the solution is just a click away. 

Once you’ve whizzed through the lessons, you can fall back on 5 language-specific guides:

  • C#
  • Javascript
  • Java
  • PHP
  • Python

RegEx101.com for on-the-fly testing and debugging

Screen Shot 2018-11-30 at 06.57.24.png

With your freshly harnessed knowledge, hop over to RegEx101.com, an online development, and debugging suite. Your test string will light up with an abundance of helpful widgets, in addition to highlighting matches:

  • full match information
  • capture groups
  • English, context-sensitive translation of what the RegEx statement means
  • a quick reference box
  • a code generator for 9 languages (Javascript, PHP, Python, C#, Java, Ruby, and Rust)
  • a means for sharing and storing your work

In not much more than an hour – with the help of these two free resources – I was able to craft an expression that succinctly extracted the information I needed, without resorting to my own obscure and undoubtedly inefficient one-off algorithm. 

 

Previous ArticleNext Article

Leave a Reply

Your email address will not be published. Required fields are marked *

A.

Android device debugging on Linux Mint: “error: insufficient permissions for device: udev requires plugdev group membership”

As I rejoiced in the achievement of finally finding a Linux distro which plays well with my Dell XPS 13 (2019 edition, model 9380), I plugged in my Moto test device, intending to continue working on an Android app. Pressing the Run button promptly made Android Studio (3.4) do its compilation magic, but got stopped in its tracks rather quickly. An angry-looking error message awaited me:

error: insufficient permissions for device: udev requires plugdev group membership

Oops, no device debugging for you.

Android Studio also left a note pointing me to their developer page on the subject. As I suspected, it seemed I had some configuration work left to get device debugging working on Linux. However, following Google’s instructions on setting up adb didn’t do much to resolve my problem. The part about adding yourself to the udev group is important, though, as it’s linked to the actual solution described in the next paragraph.

sudo usermod -aG plugdev $LOGNAME

Adds your user to the plugdev group.

Update: Someone mentioned recently that the below steps may not actually be required; just logging out and back in again at this point, should also do the trick. YMMV of course :-).

An ill-timed dog walk (let’s just say I hadn’t expected to be caught in the middle of a downpour), and a few mildly frustrated Google searches later, I ran across a blog post from 2013 (!) on the subject of “Adding udev rules for USB debugging Android devices“, by Janos Gyerik.

I will not pretend to know why this extra configuration is required, but it describes looking up the device’s identifier and adding it to the aforementioned plugdev access group, so Android Studio can properly access the USB device.

And there you go, a working USB debugging connection to my Android device, thanks to some great advice from 2013!