locdate 20230122 locdate
이중에서 사이에 있는 날짜만 추출 하고 싶습니다.
그런데 제가 아는 상식선에 코드를 입력해도 안되서요 ㅠㅠㅠ
어떤 코드를 써야 할까요?
locdate 20230122 locdate
이중에서 사이에 있는 날짜만 추출 하고 싶습니다.
그런데 제가 아는 상식선에 코드를 입력해도 안되서요 ㅠㅠㅠ
어떤 코드를 써야 할까요?
Say string is stored in str then
str.split("loc date",stringsplitoptions.none)(1)
Or
str.replace("loc date","").Trim
Or
system.text.regularexpressions.regex.matches(str,"\d{8}")(0).Value
These are to be used in assign with a string variable on left side
Str is the input string
Either of this can be used
Cheers
Thank you for your answer.
But there’s one problem.
resultstr.replace(“locdate”,“”).Trim If you write this sentence,
( locdate ) 20230122 (/locdate ) amongst locdate Only this will be extracted
20230122 20230301 I’d like to extract the date between locates.
Is there any way? I earnestly ask for your help.
Please use this
In Assign activity(left variable type is matchcollection)
Matchcol = System.text.RegularExpressions.Regex.Matches(str,"(?<=\<locdate\>).*(?=\<\/locdate\>)")
To access the matchcol
currentitem.value
Cheers
Cheers
문자열에서 숫자만 추출하는건 어떨까요?
System.Text.RegularExpressions.Regex.Replace(yourStr, “[^0-9]+”,String.Empty)
내용을 보니까 공공API에서 받은 XML 데이터에서 특정 요소만 추출하는 것을 하시는 것 같네요.
Regex 이용한 방법은 다들 잘 아시는 것 같아서 다른 방법 한번 적어봅니다.
UiPath.WebAPI.Activites 패키지(대부분 패키지 관리에서 추가해주어야 함) 내의 Deserialize XML 액티비티를 통해서 추출이 가능합니다.
이 액티비티는 XML형태의 String을 입력으로 주면 XDocument 변수로 반환해줍니다.
XDocument 변수에서 하위 요소를 탐색하는데는 아래 함수가 사용가능합니다.
.Element(이름) : 이름에 해당하는 첫 번째 자식 엘리먼트만
.Elements(이름): 이름에 해당하는 모든 자식 엘리먼트들 (배열처럼 For each 가능)
.Value : 해당 엘리먼트에서 태그명을 제외한 순수한 문자열 값
따라서 위와 같은 데이터에서 날짜만 추출하고 싶으신 경우 아래와 같은 방법으로도 추출이 가능합니다.
(*s 유무 주의)
그냥 이런 방법도 있다 정도로 참고하시면 좋을 것 같습니다.