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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

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