Calc: Regex function

I want to extract the second position of a string delimited by - (dash) characters…

case 1
LDR0077-RD2-14W-5-XXX
or case 2
LDR0077-2-14W-6-XXX

the proper result would be
Case 1: RD2
Case 2: 2

I’ve tried to solve using paranthesis and back references but I get an error.
EXPRESSION: -(*)-
REPLACEMENT: $1

REGEX(A3,-(*)-,$1)

get Err:511

any one know how to fix this???

You need to describe the original string like this: first, any characters which not a dash (several pieces), then a dash, then the characters I need are not a dash (several pieces), then again a dash and something else until the end of the string

It will be "[^-]+-([^-]+)-.*"

To take a part of the string in parentheses, write the third parameter "$1"

=REGEX(A1;"[^-]+-([^-]+)-.*";"$1")

@JohnSUN
Great answer - and it proves: “Every solution starts with a good problem description:slight_smile:

Thank you! Works like a charm!! :slight_smile: