Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

try:

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

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading