How to derive the following output using regex?

What should be the expression of output for regex?

Input: ssters1.1December1995.txts32
Ouput: 1December1995

Hi @Ruchita_Patil ,
image

The regex expression is: \d{1,}\w.*\d{4}

Have a nice day!

Thanks & Regards,
Shubham Dutta

Hi,

What if there are multiple entries and I want a generic expression?

string1.20march95.text2
str1.27June1998.txt3
ssters1.1December1995.txts32

Hi @Ruchita_Patil ,
do you want only regex or string manipulation will work?
Because for your use case string manipulation will be easy approach.

yes, that would help too

Hi @Ruchita_Patil ,
then use this: str_input.split("."c)(1)

Thanks & Regards,
Shubham Dutta

Hi @Ruchita_Patil ,
I am also attaching the code for your reference, I think that will help you more.
String_manipulation.xaml (7.0 KB)

Thanks & Regards,
Shubham Dutta

HI,

FYI, another approach:

If you want to extract dMMMMyyyy or dMMMMyy style date string, the following will work.

System.Text.RegularExpressions.Regex.Match(yourString,"\d{1,2}(January|February|March|April|May|June|July|August|September|October|November|December)\d{2,4}",System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value

Regards,

Screenshot_2022-09-08-08-28-45-66

Hi @Ruchita_Patil

How about this expression?

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\.).*?(?=\.)").Tostring

image

Regards
Gokul

@Ruchita_Patil
You can use 2 methods

  1. Regex pattern
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\.).*(?=\.)").Tostring.Trim

image
2. Use string Manipulation

Split(" ssters1.1December1995.txts32",".")(1).ToString.Trim

image