1

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.

4
  • <pedantry> Your params here are more likely the return values of functions, rather than functions themselves. </pedantry> Commented Jan 22, 2014 at 4:58
  • 1
    BTW, what's with that star at the front of your regex? If you remove that, you should match at least part of what you're looking for. That's about as close as you're gonna get, too, without going down the rabbit hole. You'd basically have to count parens or use a recursive expression to match the whole thing, and Notepad++ apparently uses POSIX REs (which are exceedingly crappy compared to PCRE). Commented Jan 22, 2014 at 5:13
  • @cHao Notepad++ has had PCRE support since version 6.0. Commented Jan 22, 2014 at 9:39
  • @user694733: Ahh. I have 5.9 for some reason. That explains a bit. :) Commented Jan 22, 2014 at 14:16

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Actually, I'd add a word boundary before the decode: \bdecode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.