Regex pattern to replace string containing special characters

Hi Team,

Need help finding out the regex pattern that will help me replacing below -

*LABEL and it’s value which contains within double quote.
(Text within double quotes may contain all different special characters and there is no fix pattern)

I am giving 2 different examples -

Input String 1 -
*QUESTION 99924 *ALPHA 1026L3 *DUMMY *VAR “version” *LABEL “SCRIPT VERSION” *PROPERTIES “ReportType=IsShell;ExcludeFromDAU=True”

Expected Output String -
*QUESTION 99924 *ALPHA 1026L3 *DUMMY *VAR “version” *PROPERTIES “ReportType=IsShell;ExcludeFromDAU=True”

Input String 2 -
*QUESTION 270 *CODES 4705L996 *RANDOM *MULTI *MIN 1 *LABEL “BARRIERS_TO_ATTENDENCE - B3” *VAR “BARRIERS_TO_ATTENDENCE” *PROPERTIES “DIMVAR=BARRIERS_TO_ATTENDENCE” *IF [#Q180,1] UIOPTIONS "? ROWPICKER"

Expected Output String -
*QUESTION 270 *CODES 4705L996 *RANDOM *MULTI *MIN 1 *VAR “BARRIERS_TO_ATTENDENCE” *PROPERTIES “DIMVAR=BARRIERS_TO_ATTENDENCE” *IF [#Q180,1] UIOPTIONS "? ROWPICKER"

@DewanjeeS Use below regex to get the LABEL and its value then use its output to replace with “”

1 Like

Thanks @Arpit_Kesharwani for your response.
The pattern you provided, that is working fine for the 1st example, but for the 2nd example it is not selecting the desired text.
Issue for the 2nd example is, after 'LABEL’ there can be multiple double quotes/ in same line.So, instead selecting the value for only *LABEL, it is selecting almost entire line.

1 Like

Hello @DewanjeeS

can you try this expression (\*LABEL).*?(?=\”)

Cheers

1 Like

@Pradeep_Shiv Thanks for your response.

Unfortunately it did not worked out with the pattern you shared (even though as per your screenshot it is working fine with same pattern only). It is only selecting till *LABEL

But I found one pattern with which it is working fine and it is -

*LABEL\s?"[^"]*"\s?

1 Like

Refer this

1 Like