ilhan
ilhan

Reputation: 39

Regex for extracting character groups ends with number and follows by a special pattern

I want to extract table.%%columnname%% info from a free text like below

GET_INFO(CUSTOMER1.%%NAME%%='TEST' AND CREDIT1.%%AMOUNT%%>1000)=1

The output i need is

CUSTOMER1.%%NAME%%
CREDIT1.%%AMOUNT%%

I have tried [a-zA-Z*][0-9].\%%.*?\%% but it didnt give me the output i need

Upvotes: 0

Views: 52

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626871

You can use

[a-zA-Z]*[0-9]+\.%%[^%]*%%

Details:

  • [a-zA-Z]* - zero or more letters ([[:alpha:]]* can also be used here)
  • [0-9]+ - one or more digits
  • \. - a dot
  • %% - %% string
  • [^%]* - any zero or more chars other than a % char
  • %% - %% string

Upvotes: 2

Related Questions