#1 2019-04-17 13:15

NexusFred
Member
Registered: 2017-08-24
Posts: 9

Keep only X digits

Hello,

I have some files like this :

Machin - 11569299 My Great Folder
10 My Wonderful Folder 20456334

I would like to keep only the 8 digits, like

Machin - 11569299 My Great Folder > 11569299
10 My Wonderful Folder 20456334 > 20456334

I know how to select this digits via Regex \d{8} but not how remove everything else big_smile

Thanks
Best Regards
Nexus

Offline

#2 2019-04-17 13:41

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Offline

#3 2019-04-17 14:37

NexusFred
Member
Registered: 2017-08-24
Posts: 9

Re: Keep only X digits

Thanks a lot. big_smilelol

I'm impressed !! The regex are so obscure to me wink

Offline

#4 2019-04-17 19:12

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Keep only X digits

NexusFred wrote:

The regex are so obscure to me wink

They are quite intimidating, but not that difficult to use once you understand the basic building blocks.

For example...

"." matches any single character.
".*" matches 0 or more of any characters.
"\b" is a word boundary, so that your 8 digits are not part of a larger sequence of letters or digits.
"\d" is a single digit (0..9).
"\d{8}" is exactly 8 digits.
"(\d{8})" is a grouping, so that it can be reused in the Replace field via $1, $2, $3 and so on, one for each group.

Offline

#5 2019-09-24 16:35

Cleoss
Member
Registered: 2018-01-19
Posts: 17

Re: Keep only X digits

den4b wrote:
NexusFred wrote:

The regex are so obscure to me wink

They are not that difficult to use once you understand the basic building blocks.
For example...

EmEditor uses a great inner spreadsheet (in its search/replace window) that can be shown by clicking the droplist button, without a requirement to download something or visit a site.
EmEd RegExp Help screenshot



I suppose ReNamer can use such a handy built-in list too, for inserting any of needed samples rapidly. I saw that ReNamer's got such drop-list, and anyway there's something to learn from EmEd imho: 

ReNamer RegEx droplist menu (helpful cheatsheet for search and replace with regular expressions)

And here is a short version of these sheets:
https://i.imgur.com/yYZGJU7.png
https://i.imgur.com/RSRAr62.png
You may save it from here and use in the future, Fred.

Offline

Board footer

Powered by FluxBB