Van Duoc
Van Duoc

Reputation: 65

Notepad++: regular expression to find functions whose parameters are also functions

So I've got a big text file and I want to search the following text:
"decode(max(ABC), null, '1', max(ABC) + 1)"

I used regular expression in Notepad++ as the following:

*decode(\s*)\(([^,]*),([^,]*),([^,]*),([^)]*)\)

But search result is not found.

Upvotes: 1

Views: 360

Answers (1)

aliteralmind
aliteralmind

Reputation: 20163

Not sure what you're looking for here, but this captures all parameter text (I'm not sure why you would want to capture the potential whitespace between decode and the opening parenthesis, so I changed it to a non-capturing group: (?:\s*)).

decode(?:\s*)\((.*)\)[^()]*$

That is, it captures

max(ABC), null, '1', max(ABC) + 1

As far as parsing that down further, into individual parameters, that is a rabbit hole as suggested in another comment.

Note that this regex assumes that no more parentheses follow the closing one for the decode function call.

You can try it out here:

http://www.myregextester.com/?r=d8c41eb7#highlighttab

And I just discovered debuggex, so I'm posting their cool image, too :)

decode(?:\s*)\((.*)\)[^()]*$

Regular expression visualization

Debuggex Demo

Upvotes: 1

Related Questions