Regex Word Boundary Example

It’s one thing to know the syntax for word boundaries in regex and it’s another to actually be able to use them. So here I’m showing you a simple example where using a beginning word boundary can come in quite handy. If you don’t know the basics of word boundaries, then watch my other vid where I show you what they’re all about.

What we’re doing here is we’re adding something to the beginning of each word. We’re turning regular column names into variables and using word boundaries is a perfect way to do this. There are other ways we could go about it, but this is a great regex word boundary example that’ll show you how to work with word boundaries in a simple way that’ll be useful to you immediately.
Now, in the example in the video, I actually could get away w/o using the word boundary. The data is simple enough that it could be done. But I took this opportunity to show you how you would use it with a word boundary to help you realize the types of things that can be done. So really the word boundary in this example is there to more ensure that you’re only taking word characters that are at the beginning of the word. And what you’ll end up with is protecting against not picking up column names that have non-word characters in the name. And as long as they don’t start with a non-word character you’ll be good.
Again, this isn’t meant to be a complete solution, but more a simple example meant to show you where this feature can be useful.

If you don’t understand the basics of regex word boundaries, you can see that vid here:

Regex Word Boundaries

Rate this video

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...