본문 바로가기

전체 글

(92)
[SonarQube][Bug] Group parts of the regex together to make the intended operator precedence explicit. Alternatives in regular expressions should be grouped when used with anchors앵커와 함께 사용할 경우 정규 표현식의 대안(alternatives)을 그룹화해야 합니다  정규식에서 앵커 ^와 $는 | 연산자보다 높은 우선 순위를 갖습니다. 따라서 ^alt1|alt2|alt3$와 같은 정규식에서 alt1은 맨 앞에 고정되고 alt3은 맨 끝에 고정되지만 alt2는 고정되지 않습니다. 일반적으로 의도된 동작은 모든 대안(alternatives)들이 양쪽 끝에 고정되는 것입니다. 이를 위해서는 대안에 non-capturing group을 사용해야 합니다. 앵커가 각각 하나의 대안에만 적용되도록 의도된 경우 앵커와 적용되는 부분 주위에 non-captur..
[JavaScript] 정규 표현식(Regular expressions) 정규 표현식이란정규 표현식, 또는 정규식은 문자열에서 특정 문자 조합을 찾기 위한 패턴입니다. 참고💡JavaScript에서는 정규 표현식도 객체로서, RegExp 객체의 exec()와 test() 메서드를 사용할 수 있습니다.String의 match(), matchAll(), replace(), replaceAll(), search(), split() 메서드와도 함께 사용할 수 있습니다. 정규 표현식 생성하기정규 표현식은 두 가지 방법으로 만들 수 있습니다.1. 정규 표현식 리터럴const re = /ab+c/;2. RegExp 객체의 생성자 호출const re = new RegExp("ab+c"); 정규 표현식 패턴 작성하기문자 클래스(Character classes)문자와 숫자처럼 다른 유형의 문자..
[Lodash] _.groupBy() 함수 설명 및 사용 예제/예시 구문(Syntax) _.groupBy(collection, [iteratee=_.identity]) 각 수집 요소를 반복 실행한 결과에서 생성된 키로 구성된 개체를 만듭니다. 그룹화된 값의 순서는 수집에서 발생하는 순서에 따라 결정됩니다. 각 키의 해당 값은 키 생성을 담당하는 요소의 배열입니다. 반복자는 다음(value) 하나의 인수로 호출됩니다. Creates an object composed of keys generated from the results of running each element of collection thru iteratee. The order of grouped values is determined by the order they occur in collection. The c..
[Lodash] _.includes() 함수 설명 및 사용 예제/예시 구문(Syntax) _.includes(collection, value, [fromIndex=0]) 값이 컬렉션에 있는지 확인합니다. 컬렉션이 문자열이면 값의 서브스트링을 확인하고, 그렇지 않으면 동일성 비교를 위해 SameValueZero가 사용됩니다. FromIndex가 음수이면 컬렉션 종료 후 오프셋으로 사용됩니다. Checks if value is in collection. If collection is a string, it's checked for a substring of value, otherwise SameValueZero is used for equality comparisons. If fromIndex is negative, it's used as the offset from the ..
[Lodash] _.find() 함수 설명 및 사용 예제/예시 구문(Syntax) _.find(collection, [predicate=_.identity], [fromIndex=0]) 컬렉션의 요소를 반복하여 조건자(predicate)가 true를 반환하는 첫 번째 요소를 반환합니다. 조건자는 세 가지 인수(값, 인덱스|키, 컬렉션)를 사용하여 호출됩니다. Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection). 매개변수(Arguments) - collection (Array|Object): 검사할 컬렉션입니다...