Please tell me how you can find the value in the next line.

\n 'host'=> 'значение', 

It is necessary to take into account that single and double quotes can be used, as well as any number of white space characters. Long puzzled, but it does not work.

  • And inside the value there may be other quotes (not the ones in which it is enclosed) or it may even be the same, then shielded with a backslash or something else? - Mike
  • They can, but God be with him. This is a common PHP hash, where you need to find the value of the host key - AlexH

1 answer 1

After the arrow, zero or more spaces, single or double quotation marks, any character to single or double quotation marks:

host['"]\s*\=>\s*['"](.*?)['"]

After comments. If you want to connect the file and get the result from it:

 $array = require('path/to/.settings.php'); $array['connections']['value']['default']['host']; $array['connections']['value']['default']['login']; $array['connections']['value']['default']['password']; 

If inside a bitrix, something like this:

 use Bitrix\Main\Config as Conf; $configuration = Conf\Configuration::getInstance(); $array = $configuration->get('connections'); $array['default']['host']; $array['default']['login']; $array['default']['password']; 
  • Thanks, but it is necessary to make a start that this is a hash and in the hash it is necessary to find the values ​​of the key host - AlexH
  • maybe you can display all the data in the whole view, maybe you don’t need regulars - Bookin
  • Unfortunately, I think that without them it will not do. Need to find connection parameters to bd ('host' 'database' 'login' 'password') Example file: gist.github.com/SidiGi/f6ceccd9e7bdd1d5e12e - AlexH
  • Well, by reference, at least the 3rd file. And what are they for? You describe the task itself, what you are trying to do. - Bookin
  • In the .settings.php file, you need to find the value of the keys 'host' 'database' 'login' 'password' - AlexH