Check dynamic String By If/Else

I have a file with String text : “curDateTime_1.1.2” , with curDatetime is dynamic String because after 1hour , I will generate new date time . How can I check dynamic String By If/Else . I tried to check if string = “*_1.1.2” and string.Equals("_1.1.2") but It doesn’t work . Any help . Thanks !

Hey @Anh_Nguyen! If you can explain your purpose better, please. But have you tried yourString.Contains("_1.1.2")?
Hope it helps!!

Hi , Firstly , I’m sorry to explain unclearly . I’ve already tried to use myString.Contains("_1.1.2") , but I have one more case myString.Contains("_1.1.1.2") . When I generate my file by if/else myString.Contains("_1.1.2") and myString.Contains("_1.1.1.2") , I saw that It was duplicated file and then I tried to use dynamic string with myString.Equals("_1.1.2") and myString.Equals("_1.1.1.2") so that I hope It won’t be duplicated file but still doesn’t work. Thanks

No problem!! Are you iterating through files and want to identify the ones that have “_1.1.1.2” or “_1.1.2” in their name?

Yes , That’s what I want . How can I do it ? . Thanks

If I understand correctly you can do this.

Let me know if this is what you need.

1 Like

No , That’s not what I mean , I used String.contains but I see problem It can’t be known how to be differrent between “_1.1.1.2” and “_1.1.2” , why ? . Because I see that when I run my loop and I see duplicate file with String “_1.1.2” . You can see that “_1.1.1.2” and “_1.1.2” is same “1.1.2” . I think that reason.

Hi @Anh_Nguyen ,

Is this what you were looking for?

image

System.Text.RegularExpressions.Regex.IsMatch(str_txtString,"_1\.1\.2")

MatchStringText.xaml (4.7 KB)

Kind Regards,
Ashwin A.K

2 Likes

Yes , Thanks . It works .

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