컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
re.regex
다음 문법 중 하나를 사용하여 YARA-L 2.0에서 정규 표현식 일치를 정의할 수 있습니다.
설명
이 함수는 문자열에 제공된 정규 표현식과 일치하는 하위 문자열이 포함되면 true
를 반환합니다. 정규 표현식의 시작 또는 끝 부분에 .*
를 추가할 필요는 없습니다.
참고
- 정확한 문자열 또는 프리픽스나 서픽스만 일치하는 항목을 찾으려면 정규 표현식에
^
(시작) 및 $
(종료) 앵커 문자를 포함하세요.
예를 들어 /^full$/
은 "full"
과 정확하게 일치하지만 /full/
은 "fullest"
, "lawfull"
, "joyfully"
와 일치할 수 있습니다.
- UDM 필드에 줄바꿈 문자가 포함되면
regexp
는 UDM 필드의 첫 번째 줄만 일치합니다. 전체 UDM 필드 일치를 적용하려면 (?s)
를 정규 표현식에 추가합니다. 예를 들어 /.*allUDM.*/
을 /(?s).*allUDM.*/
으로 바꿉니다.
- 문자열 다음에
nocase
한정자를 사용하여 검색 시 대소문자를 무시하도록 지정할 수 있습니다.
매개변수 데이터 유형
STRING
, STRING
매개변수 표현식 유형
ANY
, ANY
반환 유형
BOOL
코드 샘플
예 1
// Equivalent to $e.principal.hostname = /google/
re.regex($e.principal.hostname, "google")
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 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\u003eThe \u003ccode\u003ere.regex\u003c/code\u003e function in YARA-L 2.0 is used to check if a string contains a substring that matches a given regular expression, and is supported in Rules and Search.\u003c/p\u003e\n"],["\u003cp\u003eThere are two ways to define regular expression matching in YARA-L 2.0: using the \u003ccode\u003e$e.field = /regex/\u003c/code\u003e syntax or by using the \u003ccode\u003ere.regex($e.field, \u003c/code\u003eregex\u003ccode\u003e)\u003c/code\u003e function.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ere.regex\u003c/code\u003e function automatically checks for substrings, so adding \u003ccode\u003e.*\u003c/code\u003e at the beginning or end of the regular expression is unnecessary.\u003c/p\u003e\n"],["\u003cp\u003eTo ensure exact string matching or to match prefixes or suffixes, use the \u003ccode\u003e^\u003c/code\u003e and \u003ccode\u003e$\u003c/code\u003e anchor characters within the regular expression, and add a \u003ccode\u003e(?s)\u003c/code\u003e modifier for full multi-line field matching.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports case-insensitive searches using the \u003ccode\u003enocase\u003c/code\u003e modifier after the strings.\u003c/p\u003e\n"]]],[],null,["### re.regex\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search)\n\nYou can define regular expression matching in YARA-L 2.0 using either of the following syntax:\n\n- Using YARA-L syntax --- Related to events.\n The following is a generic representation of this syntax:\n\n $e.field = /regex/\n\n- Using YARA-L syntax --- As a function taking in the following parameters:\n\n - Field the regular expression is applied to.\n - Regular expression specified as a string.\n\n The following is a generic representation of this syntax: \n\n re.regex($e.field, `regex`)\n\n#### Description\n\nThis function returns `true` if the string contains a substring that matches the regular expression provided. It is unnecessary to add `.*` to the beginning or at the end of the regular expression.\n\n##### Notes\n\n- To match the exact string or only a prefix or suffix, include the `^` (starting) and `$` (ending) anchor characters in the regular expression. For example, `/^full$/` matches `\"full\"` exactly, while `/full/` could match `\"fullest\"`, `\"lawfull\"`, and `\"joyfully\"`.\n- If the UDM field includes newline characters, the `regexp` only matches the first line of the UDM field. To enforce full UDM field matching, add a `(?s)` to the regular expression. For example, replace `/.*allUDM.*/` with `/(?s).*allUDM.*/`.\n- You can use the `nocase` modifier after strings to indicate that the search should ignore capitalization.\n\n#### Param data types\n\n`STRING`, `STRING`\n\n#### Param expression types\n\n`ANY`, `ANY`\n\n#### Return type\n\n`BOOL`\n\n#### Code samples\n\n##### Example 1\n\n // Equivalent to $e.principal.hostname = /google/\n re.regex($e.principal.hostname, \"google\")"]]