Regex is not something I’ve ever taken the time to learn. I’m trying to do something that I hope is simple.
I have a string that’s something like this: 2021 Competition Name
What I want is to remove the leading year as well as the space following it, so it looks like this: Competition Name
At best I can get regex to remove the leading year, but I can’t figure out how to also remove the space, so right now I end up with this: •Competition Name (The dot is a space)
I can create another column to trim whitespaces, and that works fine, but I was hoping to accomplish the removal of the year as well as the trim with a single regex column.
I was wondering if anybody had any insight on how to accomplish this.
That’s not working for me. Here is a little more context. What I’m trying to do is replace some old vlookup that was combines with some regex logic in my sheet. What’s supposed to happen is that I take a competition name, that includes a year, strip off the year, and then ultimately use that stripped value to create a relation to an Images resource table. The competition is year based, but the image for each particular competition remains the same. This allows a user to create a new competition record, with a name that includes the year, but pulls from the same images resource.
This is what I am using. It extracts everything BUT the year, which is what I want. But it obviously still includes the space between the year and the rest of the string, because it’s not numeric.
Using your regex, it instead returns only the decimal digits and the space, which is the opposite of what I’m looking for.
Hope that makes mores sense. Right now, I can take the regex result from (\D+) and then use the trim plugin, so I’m completely fine with that method, but I wanted to see if I could do it all within the regex extract.
That’s the ticket. I was using the wrong plugin. As you can tell, I haven’t dug really deep into the plugins.
I try to stick to the original glide columns if at all possible. Thanks for the assist!
Your second method works too. I need to sit down sometime and learn regex.
Sometimes I get into a rabbit hole where something seems so dang simple, and I keep searching and trying things without making any progress. Eventually, I begin to question myself, and begin to wonder if what I’m trying to do is even possible.
haha, yes I can relate to that. In times like that, I find that setting it aside for a while and working on something else almost always helps. Or go for a walk, or sleep on it. Then come back at it with a fresh mind. Inevitably, I find the answer staring me in the face
As an aside, of those two regex options above, the first would be (ever so) slightly more efficient. That’s because it will stop as soon as it hits the first non-matching character, whereas the second will continue to the end of the string.
I’ll have to check out that book. We use a very small amount of regex at work, and at most, only a couple of the other developers deal with that stuff, so I’ve never had to touch it. Now SQL…on the other hand…I’ve done some crazy things with that.