Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Java 8

"
(.*?)(?:\(#\d+\))?$
"
gm

Description

This regex expression is useful for extracting only the text string from a value in a column that may contain values from individual rows with repeat strings tagged with a suffix. For example - Row 1: "Sales (#1)", Row 2: "Sales Match (#2)". From the shared examples, this regex will extract the text "Sales" and "Sales Match."

Submitted by nilotpalc - a year ago