Reputation: 16373
I wish use a regex to be used in Sublime Text 3
to find commands like
get :action, id: 1, name: 'John',
children: 3
My initial attempt is get :[\w]*,[^\n]*
. This will work if the command is on a single line i.e
get :action, id: 5, name: 'Chris'
but does not work when the command is written over several lines with a comma continuation. What is the regex that will work with a multi-line command?
The Sublime Text find operation uses Perl Compatible Regular Expressions (PCRE).
Upvotes: 0
Views: 48
Reputation: 16065
You could use
get :\w+(?:,\n?[^\n,]+)+
get :
literal\w+
one or more word characters(?:
begin sub-expression
,
literal\n?
an optional newline[^\n,]+
at least one character that isn't a newline or a comma)+
match this sub-expression at least onceUpvotes: 1