Question: I make the following query

```
neo4j-sh (?)$ start n=node(*) where n.name  =~ 'u(.*)' return n; 
==> +-----------------------+
==> | n                     |
==> +-----------------------+
==> | Node[311]{name:"u1"}  |
==> | Node[312]{name:"u2"}  |
==> | Node[313]{name:"u3"}  |
==> | Node[314]{name:"u4"}  | 

```

I want to add a "userId" property and set it the number in the name key. I mean I want 

```
==> +-----------------------+
==> | n                     |
==> +-----------------------+
==> | Node[311]{name:"u1", userId:'1'}  |
==> | Node[312]{name:"u2", userId:'2'}  |
==> | Node[313]{name:"u3"},userId:'3'  |
==> | Node[314]{name:"u4"}, userId:'4' | 

```

Now I need to strip the numbers from n.name.
How can I do this? How can I get the value from the (.\*) in regex?

Answer: 
You can't do that in Cypher (as far as I know)--regex is just for matching.

If it's always just a single letter in front of it, you can take the substring:

```
start n=node(*) 
set n.userId = substring(n.name, 1)

```
You should be able to use matched groups with an APOC `apoc.text.regexGroups` function:

```
MATCH (a:AppJar)-[:CONTAINS]->(b)
WHERE b.fileName STARTS WITH "/BOOT-INF/lib/event-"
WITH a, b, last(last(apoc.text.regexGroups(b.fileName, '/BOOT-INF/lib/event-([\\d\\.]+).jar'))) as version
SET b.version = version
RETURN a.appName, b.fileName, b.version
LIMIT 100

```

it is a different query but should be applicable to your data as well