Hi,
I have files names such as
998dtag
999 version
1000telstra
1001 006113
1002111567
1003 telsra
I need to remove serial number and copy only
Dtag
Version
Telstra
006113
111567
Telsra
^\d{3,4}\s?
fileNames = Directory.GetFiles("C:\YourDirectoryPath")
For Each file In fileNames
processedName = System.Text.RegularExpressions.Regex.Replace(file, "^\d{3,4}\s?", "")
End
Hope it helps!!
(?<=\d{4})\d+|(?<=\d{4}\s)\d+|(?<=\d+\s*)[a-z]+
or
System.Text.RegularExpressions.Regex.Replace(currentMatch.ToString,"^(\d{3,4})","").Trim
Hi,
I have files names such as
996006345
997115894
998dtag
999 version
1000telstra
1001 006113
1002111567
1003 telsra
I need to remove serial number and copy only
006345
115894
Dtag
Version
Telstra
006113
111567
Telsra
Hi,
I have files names such as
996006345
997115894
998dtag
999 version
1000telstra
1001 006113
1002111567
I need to remove serial number and copy only
006345
115894
Dtag
Version
Telstra
006113
111567
System.Text.RegularExpressions.Regex.Replace(STR,"^(\d{3,4})","",System.Text.RegularExpressions.RegexOptions.Multiline)
Please try this expression
(?<=9\d{2})\d+|(?<=1\d{3}\s*)\d{5,}|(?<=\d+\s*)[a-z]+
System.Text.RegularExpressions.Regex.Replace(STR,"(?<=9\d{2})\d+|(?<=1\d{3}\s*)\d{5,}|(?<=\d+\s*)[a-z]+","",System.Text.RegularExpressions.RegexOptions.Multiline)
If you are able to extract your filenames if not please update .If my regex works for you then close this loop by marking as solution
I have taken serial number from 996 to 1005 as example but currently serial number at 950 serial number
@Meghana_Bonu1
Whatever serial number it is the regular expression works for you please check once and update here.if it does not work please put that input so i change regex
Estra
version
Tesla
Dtag
Colt
00611424
000567—starts with 000
Bt roj
Fred
645679
11533
10839
These are the different types of filenames
Sometimes after the serial number I will get space and sometimes not
Can you share all type of files names along with the expected output so that I will try to help out with regex.
Regards
These are the list of files names
Output:
Estra
version
Tesla
Dtag
Colt
00611424
000567—starts with 000
Bt roj
Fred
645679
11533
10839
Input:
995version
996 version
99700611424
998 00611424
999dtag
1000fred
1001 000567
I will get above list of filenames along with serial number sometime with space and without space. I need to extract only filename
Currently serial number at 950
Please check with the below regex expression:
([a-zA-Z]+)|(00)?\d{6}$
I have extracted the data as per your requirement using the below syntax please check and let me know if still any modifications needed:
System.Text.RegularExpressions.Regex.Match(currentMatch.ToString,"([a-zA-Z]+)|(00)?\d{6}$",System.Text.RegularExpressions.RegexOptions.Multiline).Value.Trim
Regards







