문자열이 특정 형식으로 되어있는지 확인하는 방법

안녕하세요 문의드립니다

“2022-02-03”
“2022-03-03”
“20220104”

이런 형태의 string 값이 있을 때
형식이 “2022-02-03” 형식으로 이루어져있는지 아닌지를 확인하고싶은데요
예를들어 “2022-02-03” 형식이 아닌 "20220304"이런 형식으로 되어있다면 false값을 반환하고싶습니다
어떤 함수를 사용해야될까요?

Hi @momoninimo

You can use regex activity to achieve that

This patter checks if there is a dddd-dd-dd pattern in your string (d is a digit).

Right side of Assign activity:
System.Text.RegularExpressions.Regex.IsMatch(yourString, "\d{4}-\d{2}-\d{2}")

yourString is string you want to input. For example “2022-02-03”.

Left side of Assign activity:
isMatch is a boolean type variable, it becomes True if string matches.

HI @momoninimo
Try this expression

DateTime.TryParseExact("YourDateVariableString",{"yyyy-MM-dd"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None,Nothing)


You can give this directly in the if

Regards
Sudharsan

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