Extract all number of 6 digits in all records

Heremion

New Member
Joined
Nov 29, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello!

I searched for a while how to fix my problem but none of the solutions works fine, so I come here hoping some new help :)

This is an example of string I got in my table :
417720;2;2003;431967;432071;432135;432071;432504;432135;432504;433695

I would like to extract all number of 6 digits in my string and have in return this
417720;2003;431967;432071;432135;432071;432504;432135;432504;433695 (the 2 was removed)

I tried with regex like this in R language
VBA Code:
# 'dataset' contient les données d'entrée pour ce script
library("stringr")
pattern <- "(([0-9]{6})*[;]*)*"
cleanRegEx <- str_extract(dataset$myCol, pattern)
Anomalies <- within (dataset, {Regex= cleanRegEx})

But when it works, it extracts only le first number of 6 digits.

I also tried the str_extract_all but I got everytime some errors.

Do you have any idea to get what I expected please ?

Thanks for your time :)
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top