FORUM COMMUNITY IDEAS SHOWCASE LEARNING CENTER

Extract characters using Regex


#1

Hello guys,

I’m having some trouble to extract using regex. I have an input that accepts a 6-digit number. I’ve configured this input to be of type Text (numbers only). And in another input filed I’m trying to extract pairs of this 6-digit “text”, using regex.

When I use (\d{2}), it takes the first 2 digits (or characters).

But how can I extract the 3rd and 4th digits? How can I extract the 5th and 6th? It wud be something similar to substring(element, start_position, size).

Example:
Input: 123456

What I need to extract:
Output 1: 12
Output 2: 34
Output 3: 56

Got it?
Any help? Advice?

Cheers.


#2

You have the correct regex i.e. \d{2}. All you need after your “extract with Regex”, is to follow up with “item 1” (digits 1+2) or “item 2” (digits 3+4) or “item 3” (digits 5+6). As per https://regexr.com/3pjsm, you’ll see there’s 3 pairs of digits extracted. Let me know if you need further clarification :slight_smile:


#3

Thank you @sherman, you are right! So close… hahahaha cheers