컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
strings.trim
strings.trim(string_to_trim, cutset)
설명
지정된 문자열에서 선행 및 후행 화이트 스페이스를 자릅니다. 또한 입력 문자열에서 원치 않는 문자 (cutset 인수로 지정됨)를 삭제합니다.
매개변수 데이터 유형
STRING
, STRING
반환 유형
STRING
코드 샘플
다음은 사용 사례 예시입니다.
예 1
다음 예에서는 동일한 문자열이 입력 문자열과 cutset으로 전달되어 빈 문자열이 생성됩니다.
strings.trim("str", "str") // ""
예 2
다음 예시에서는 빈 문자열이 cutset으로 전달되므로 삭제할 문자가 cutset에 지정되지 않아 원래 문자열 str이 결과로 생성됩니다.
strings.trim("str", "") = "str"
예시 3
다음 예시에서는 입력 문자열이 이미 비어 있고 삭제할 문자가 없으므로 함수가 빈 문자열을 생성합니다.
strings.trim("", "str") = ""
예 4
다음 예에서 trim 함수는 다음을 삭제하므로 함수는 str을 생성합니다.
- 'a aastraa aa '의 후행 공백
- 컷셋에 지정된 문자 (공백, a)
strings.trim("a aastraa aa ", " a") = "str"
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-29(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-29(UTC)"],[[["\u003cp\u003e\u003ccode\u003estrings.trim\u003c/code\u003e removes leading and trailing whitespace from a string, as well as specified characters within the string.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecutset\u003c/code\u003e parameter defines the characters to be removed from the input string in the \u003ccode\u003estrings.trim\u003c/code\u003e function.\u003c/p\u003e\n"],["\u003cp\u003eIf the \u003ccode\u003ecutset\u003c/code\u003e contains all the characters of the \u003ccode\u003estring_to_trim\u003c/code\u003e, the function returns an empty string.\u003c/p\u003e\n"],["\u003cp\u003eWhen the \u003ccode\u003ecutset\u003c/code\u003e is an empty string, nothing is trimmed, and the original string is returned.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003estrings.trim\u003c/code\u003e is available for use in both Chronicle Rules and Search.\u003c/p\u003e\n"]]],[],null,["### strings.trim\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n strings.trim(string_to_trim, cutset)\n\n#### Description\n\nTrims leading and trailing white spaces from a given string. Also, remove unwanted characters (specified by the cutset argument) from the input string.\n\n#### Param data types\n\n`STRING`, `STRING`\n\n#### Return type\n\n`STRING`\n\n#### Code samples\n\nThe following are example use cases.\n\n##### Example 1\n\nIn the following example, the same string is passed as the input string and the cutset, which results in an empty string. \n\n strings.trim(\"str\", \"str\") // \"\"\n\n##### Example 2\n\nIn the following example, an empty string is passed as the cutset, which results in the original string str because there are no characters specified in the cutset to remove. \n\n strings.trim(\"str\", \"\") = \"str\"\n\n##### Example 3\n\nIn the following example, the function yields an empty string because the input string is already empty and there are no characters to remove. \n\n strings.trim(\"\", \"str\") = \"\"\n\n##### Example 4\n\nIn the following example, the function yields str because the trim function removes the following:\n\n- trailing whitespace in \"a aastraa aa \"\n- the characters specified in the cutset (space, a)\n\n strings.trim(\"a aastraa aa \", \" a\") = \"str\""]]