Extract parts of string with Regex

I’m going around in never ending circles with Regex and I’m not sure it is even the way I should be approaching my problem.

I have a string of 17 alphanumeric characters (e.g. AD6HU987RKE06G54T) and I need to display them, in a Text element, in chunks as is done with credit card numbers. They need to be formatted as 3-5-3-6 so my example would look like AD6-HU987-RKE-06G54T.

Can anyone point me in the direction of success?

Try this plugin - it lets you define your own pattern and has worked well for me in various scenarios: New Plugin - Input Formatter

1 Like

Take a look at the text operators in the reference (or just in the drop downs) — just chain your representation together in an expression.

Example, your first 4 chars are ID:truncated to 3-… etc

Thank you @romanmg I use that plugin myself. In fact I use it when inputting that very field but never thought to use it when displaying - 4 hours down the drain :frowning:

Will do @keith - more learning - I love it.

All the JS style operators are there (though this isn’t quite as slick as if you can express it as a regex).

Also, don’t feel bad: I spent more time that I shoulda recently trimming white space from an input via regex… but there’s already a built-in operator for that. Doh!

It’s the human tendency to overcomplicate everything.

Maybe! With respect to the white space thing, I just wasn’t EXPECTING it would exist so didn’t go looking for it. This is kind of a problem with Bubble operators — not easy to search for info on them in context.

(The operator in question, BTW is :trimmed … which I never figured was “trim white space” — in my head, I’d assumed :trimmed was some variation on :truncated.)

@Keith I thought exactly the same about trimmed and did a double take when I saw recently that it was a space remover.

We’ve had a power outage here for hours but it just came back and I was straight in to try out the text operators. I’m already using the plugin Gaby mentioned so that was easy but I wanted to see what I could do with the operators and had it working in minutes. I think it is time I took time out to reread the bubble manual/reference now I’ve built stuff and I can relate the text to reality. There are so many hidden goodies it amazes me every day.

The Reference doesn’t really make for a good read, but a useful thing to do is spend some time clicking on the contextual help links that pop up when you hover over elements in the interface.

I find when I read the entire section, I usually learn something. There’s totally a lot of goodies hidden in there!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.