Reputation:
Sorry, for the badly named topic. I'm looking for a efficient regular expression to match the following:
[2014-11-13 13:05:04] [path/to/class.instagram.php] Options: array (
'client_id' => '',
'client_secret' => '',
'object' => 'tag',
'object_id' => 'rwar',
'aspect' => 'media',
'callback_url' => 'http://www.localthisday.nl/instagram.callback.php',
)
I want it to be split up so it looks like this:
1. [2014-11-13 13:05:04]
2.[path/to/class.instagram.php]
3. Options: array (
'client_id' => '',
'client_secret' => '',
'object' => 'tag',
'object_id' => 'rwar',
'aspect' => 'media',
'callback_url' => 'http://www.localthisday.nl/instagram.callback.php',
)
I'm using this one at the moment:
(\[(.*)\])(\s{1})(\[(.*)\])(\s{1})(.*)/gmi
I know, it's not a very good one, that's probably why it doesn't work the way I want it to work. Problem is; it's a multi-line string, and for some reason it does not work multi-line. Could someone please help me? I'm not that good in regular expressions unfortunately.
Upvotes: 0
Views: 132
Reputation: 174836
Just replace the last (.*)
with ([\S\s]*)
in your regex.
/(\[.*\])\s(\[.*\])\s([\S\s]*)/gmi
See the captures at the right side in the above demo link.
Upvotes: 1
Reputation: 67988
(\]|\))
Try this.Replace by $1\n
.See demo.
http://regex101.com/r/pQ9bV3/32
var re = /(\]|\))/gm;
var str = '[2014-11-13 13:05:04] [path/to/class.instagram.php] Options: array (\n \'client_id\' => \'\',\n \'client_secret\' => \'\',\n \'object\' => \'tag\',\n \'object_id\' => \'rwar\',\n \'aspect\' => \'media\',\n \'callback_url\' => \'http://www.localthisday.nl/instagram.callback.php\',\n)';
var subst = '$1\n';
var result = str.replace(re, subst);
Upvotes: 0