Home > Blockchain >  Formula/regex to remove/replace everything except number(id) in google sheets
Formula/regex to remove/replace everything except number(id) in google sheets

Time:08-17

I have ~20k rows like:

/CNTI=1/USERID=1/ACCTNUM=1/USERTYPE=1/NUMLISTS=0/ASTATUS=0x0        
/CNTI=1/USERID=2/ACCTNUM=5/USERTYPE=3/NUMLISTS=120/ASTATUS=0x0
/CNTI=1/USERID=321/ACCTNUM=6/USERTYPE=1/NUMLISTS=0/ASTATUS=0x0                                                                                          

What I'm trying to do is to remove everything and leave only the ID number. In the example above - 1,2, 321...

I have tried with regex on google sheet -> Find and Replace -> Search with regex and I have searched for /CNTI=*/ in order to delete firs all CNTI's then ACCTNUM and so on but the function says that the search term isn't found. Tried also /CNTI=~/, /CNTI=*?/ still not found.

Can someone help with formula or proper regex which I can use?

CodePudding user response:

try:

=INDEX(IF(A1:A="";;IFNA(REGEXEXTRACT(A1:A; "USERID=(\d )"))*1))

enter image description here

  • Related