如何使用RegEx使用变量[关闭]

I tried reading online tutorials about RegEx, but none of them give me a clear picture of how to find and replace with variables. As I now understand from the comments, regex is for searching only, so to specify, I want to do this using the Atom text editor. Alternatively using php.

What I want to do is to find and replace in this way:

"resolution": "800x600"  ---> "width":"800", "height":"600"

"resolution": "1024x768"  ---> "width":"1024", "height":"768"

Can anyone please explain how to do this, and how to use variables when replacing with regex?

PHP solution is

$re = "/.*?(\\d+)x(\\d+)/m"; 
$str = "\"resolution\": \"800x600\""; 
$subst = "\"width\" : \"$1\", \"height\" : \"$2"; 

$result = preg_replace($re, $subst, $str);

IDEONE DEMO

As far as atom editor is concerned it supports back references as $1 etc. as mentioned here and here