Today, we'll be reviewing the intricacies of regular expressions. More specifically, we'll discuss both how and why you should use positive/negative lookahead ands lookbehinds in your regular expressions. Originally meant to be a quick tip, this screencast ended up a bit longer than expected, at around eighteen minutes.
After viewing the video, keep in mind that, for any given task, there are a plethora of ways to match your desired text. For example, when matching a Twitter username – as we did in the video – you could also use a non-word-boundary, rather than a positive lookbehind.
\B@\S+\b // matches any Twitter username, like "@nettuts"
The key is to find the right tool for the job.
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post