$re = '/(?<action>[a-zA-Z]+)@\/(?<dev_path>.*)\/(?<subsystem>[a-zA-z]+)\/(?<name>[a-zA-z]+)/';
$str = 'change@/devices/soc/9000000.usb/power_supply/usb
change@/devices/soc/9000000.usb/power_supply/usb
change@/devices/virtual/android_usb/android0
change@/devices/soc/99999999.i2c/i2c-3/3-0025/power_supply/battery
change@/devices/soc/9000000.usb/power_supply/usb
change@/devices/soc/9000000.usb/power_supply/usb
change@/devices/soc/soc:usb_charger/power_supply/usb_charger
change@/devices/soc/soc:mains_charger/power_supply/mains_charger
change@/devices/soc/99999999.i2c/i2c-3/3-0025/power_supply/battery
change@/devices/soc/99999999.i2c/i2c-3/3-0025/power_supply/battery
change@/devices/soc/99999999.i2c/i2c-3/3-0025/power_supply/battery
change@/devices/soc/soc:usb_charger/power_supply/usb_charger
change@/devices/soc/soc:mains_charger/power_supply/mains_charger
change@/devices/soc/99999999.i2c/i2c-3/3-0025/power_supply/battery
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php