특수 문자와 함께 열에서 처음 4자 제거안녕하세요,
샘플 설명인 열이 있고 모든 행에서 제거하고 싶은 설명 앞에 항상 ~숫자가 있습니다. 한 행에만 "~"가 있습니다. 예를 들어.
견본:
126: 설명 AB
291: 설명 XYZ
~619: 설명
샘플 열 내의 모든 행에서 "~", 처음 3자리 숫자 및 ": "(공백 포함)을 제거하는 JSL 스크립트가 있습니까? 내가 보고 있는 데이터에는 항상 : 및 공백과 함께 앞에 3자리 숫자가 있습니다. 문제는 행 중 하나에서 ~를 제거하는 것입니다.
도움을 주셔서 감사합니다
조롱
자동화 및 스크립팅윈도우Re: 열에서 특수 문자와 함께 처음 4자를 제거합니다.다음은 ":"을 구분 기호로 사용하여 마지막 "단어"에서 기본적으로 선행 공백을 제거하는 한 가지 방법입니다. Regex를 포함한 다른 방법이 있습니다.
/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN. BY USING THE CODE, YOU AGREE TO THESE TERMS. YOUR USE OF THE CODE IS AT YOUR OWN RISK. JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose. The Code is designed to add functionality to the Software but has not necessarily been tested. Accordingly, JMP makes no representation or warranty that the Code will operate error-free. JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages. Except as otherwise provided above, the Code is governed by the same agreement that governs the Software. If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.
*/
Names Default To Here (1);
//make data table
dt = New Table( "Untitled",
Add Rows( 3 ),
New Column( "Sample",
Character,
"Nominal",
Set Values(
{"126: Description AB", "291: Description XYZ", "~619: Description"}
)
)
);
//remove unwanted characters
for each row (dt,
:Sample = trim (word (-1, :Sample, ":"))
);Re: 열에서 특수 문자와 함께 처음 4자를 제거합니다.안녕 @햄스 ,
유지하려는 부분은 항상 공백으로 문자열의 나머지 부분과 구분되므로 다음과 같은 재코딩 공식을 사용하여 첫 번째 단어를 제외한 모든 "단어"를 유지할 수 있습니다(문자와 숫자가 혼합되어 있지만 공백으로 구분하지 않음). 샘플 설명이 있는 열 이름으로 "열 1" 열 이름을 간단히 변경할 수 있습니다.
Recode(
:Column 1,
{Word(
[2 -1],
_rcNow,
Get Whitespace Characters() ||
Get Punctuation Characters( Exclude Chars( "'-" ) ),
Unmatched( _rcNow )
)}
)
이 다른 옵션이 도움이 되기를 바랍니다.
Re: 열에서 특수 문자와 함께 처음 4자를 제거합니다.이를 수행하는 방법에는 여러 가지가 있습니다. 아래는 정규식을 사용하는 한 가지 옵션입니다.
Regex("126: Description AB", "~?\d{3}: (.+)$", "\1");
Regex("291: Description XYZ", "~?\d{3}: (.+)$", "\1");
Regex("~619: Description", "~?\d{3}: (.+)$", "\1");
https://regex101.com/r/nMilGt/1 정규식을 조금 설명합니다
