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

Time:12-19

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

CodePudding user response:

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

CodePudding user response:

Try this one [a-zA-Z*][0-9]*\.\%\%[a-zA-Z*][0-9]*\%\%

  • Related