How to extract a string using regular expression

When we have this string how do we extract the following. I tried to use previous examples and reuse the same expressions but I cant get it right. I wanted to extract the following strings without using hardcoding

1.RachelGreen
2. 40874

So far I can extract only 04042020

ext_name

@samuel.chaane
if its a folder give try on surrounding some patterns with
.*\YOUROLDPATTERN\.*

for a file extract at first the filename with the help of Path… and it adequate method e.g. get filenamewithout extension etc.

just give us a full string and we can test our ideas

1 Like

This expression (?<=\d{0})\d+(?=)
can extract 04042020 without any hard coding. I am trying to find a similar expression for 40874 and RachelGreen

Remember the solution you provided, it works on the same file name. I am trying to create similar expressions
pprRobot

please share full string. this allows us to better validate our ideas. thanks

1 Like

Thanks I am sorted. I used this to remove the extensions from the file and only get the file name.
Filename= path.getfilename(item.tostring).split("."c)(0)

I used this to remove the file extensions and the expressions worked

Filename= path.getfilename(item.tostring).split("."c)(0)

Perfect
have a look on this method as you can shorten the statement
grafik

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.