데이터 세트의 열 이름에서 선행 문자(::) 및 끝 문자(;;)를 제거하는 방법안녕하세요, 시작 부분에 ::와 같은 특정 기호를 제거하는 방법을 조언해 주시겠습니까? ;; 사용 가능한 경우 열 이름 끝에
예시:
::컬럼명;; --> 열 이름
::컬럼명::XYZ;ABC;; --> 열 이름::XYZ;ABC
123::ColumName --> 변경 사항 없음 123::ColumName
데이터 테이블스크립팅창Re: 데이터 세트의 열 이름에서 선행 문자(::)와 끝 문자(;;)를 제거하는 방법다음은 원하는 작업을 수행하는 간단한 스크립트입니다.
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
theName = Column( dt, i ) << get name;
If( Left( theName, 2 ) == "::",
theName = Substr( theName, 3 )
);
If( Right( theName, 2 ) == "::",
theName = Substr( theName, 1, Length( theName ) - 2 )
);
Column( dt, i ) << set name( theName );
);
Re: 데이터 세트의 열 이름에서 선행 문자(::)와 끝 문자(;;)를 제거하는 방법이름 구축을 위한 몇 가지 추가 옵션
// Option1, using Starts With, Ends With and Substr
If(Starts With(col_name, "::"),
col_name = Substr(col_name, 3);
);
If(Ends With(col_name, ";;"),
col_name = Substr(col_name, 1, Length(col_name) - 2);
);
모든 경우에 작동하는지 확실하지 않음
// Option2, using Regex
regex_pattern = "(?:^::)(.*)(?:;;$)";
Regex(col_name, regex_pattern, "\1");