Hi ,I hve an exception list in which I have mentioned the format.if the number matches with the format then ignore it.currently I have 2 format i.e xxxxx.xx,xx.xxxxxx.xx and in the future it will increase it.
TIA
exceptionPatterns = New List(Of String) From {
"^\d{5}\.\d{2}$",
"^\d{2}\.\d{6}\.\d{2}$"
}
numbersList = New List(Of String) From {"12345.67", "12.345678.90", "123.456", "98765.43"}
filteredNumbers = numbersList.Where(Function(number) Not exceptionPatterns.Any(Function(pattern) Regex.IsMatch(number, pattern))).ToList()
Hi @Cuberoot
Assign Activity:
formats = New List(Of String) From {"^\d{5}\.\d{2}$", "^\d{2}\.\d{6}\.\d{2}$"}
numbers = New List(Of String) From {"12345.67", "12.123456.78", "123.45", "98765.43"}
filteredNumbers = numbers.Where(Function(num) Not formats.Any(Function(format) System.Text.RegularExpressions.Regex.IsMatch(num, format))).ToList()
For Each num In filteredNumbers
Console.WriteLine(num)
Next
Hope it helps!!
if in future I will add more exception format without updating it,did it work?
New List(Of String) From {"^\d{5}\.\d{2}$", "^\d{2}\.\d{6}\.\d{2}$"}
In this you can add your new formats.it works
Can’t we make it dynamic , if it find the format in the file then it will automatically ignore it without making any changes in the code
Hi @Cuberoot
Share your number formats so that we will be able to help you in making the regular expressions dynamic.
Regards
@Cuberoot
Formats are dynamic only,if you find new format please add in that list,So basically Upto now whatever possible formats we have we placed in that list,In future there are possibilities to get new formats then we had to add that in list
Please specify the possible formats
It depends on the user
@Cuberoot
Use Wild cards \d{5} like \d+ or \d{5} as \d*
- means 1 toInfinity number of numbers
- Means 0 to infinity
I hope this will help you
Hi @Cuberoot
If it totally depends on the user how many numbers he enters, make the regular expression dynamic or use an single regular expression to extract any kind of numbers you get from the user like below:
Hope you understand!!
