본문 바로가기

Develop

(163)
콤마 자바스크립트에서 숫자를 표기할때 3자리마다 콤마를 찍어줘야 할 때가 있다 자주 사용하는 기능인데 매번 만들기란 여간 귀찮은게 아니다.콤마찍기12345//콤마찍기function comma(str) { str = String(str); return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');}콤마풀기12345//콤마풀기function uncomma(str) { str = String(str); return str.replace(/[^\d]+/g, '');}복사 붙여넣기로 사용하자!input box에서 사용자 입력시 바로 콤마를 찍어주기 위한 함수도 추가 한다.12345function inputNumberFormat(obj) { obj.value = comma(unc..
request 내용 확인 HTTP method 확인String method = request.getMethod();cs ContextPathString cp = request.getContextPath();//: /studycs 요청 URLString url = request.getRequestURL().toString();//http://localhost:9090/study/0222/test3_ok.jsp String path = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); //http://localhost:9090/studycs URL에서 스키마, 서버이름, 포트번호를..
공백, 줄바꿈 등 제거 $('#id').val().replace(" ", "") -> 첫번째 공백 1개만 없어짐. $.trim($('#id').val()) -> 글자사이 공백은 안없어짐. $('#id').val().replace(/ /g, ''); -> 모든 공백 없어짐. $('#id').val().replace(/,/g, ''); -> 모든 콤마(,) 없어짐. function trim(value){value = value.replace(/\s+/, "");//왼쪽 공백제거value = value.replace(/\s+$/g, "");//오른쪽 공백제거value = value.replace(/\n/g, "");//행바꿈제거value = value.replace(/\r/g, "");//엔터제거return value;}
숫자 체크 (isNaN, jQuery.isNumeric, 정규식) 자바스크립트에서 숫자 체크는 정규식, isNaN, jQuery 등 여러가지 방법이 있습니다.아래에 코드와 테스트한 결과를 올려놓았으니 본인이 원하는 상황에 맞게 사용하세요.isNaN( value )자바스크립트에서 isNaN 은 숫자가 아닌 값을 찾는 함수입니다.isNaN ( value ) 의 value가 숫자가 아니라면 true, 숫자라면 false라는건데..원하는대로 나올까요?숫자가 true로 반환하려면 반대로 해야겠죠? !isNaN( value )로 테스트 해봅시다.123456789101112131415161718192021!isNaN( "-10" ) // true!isNaN( "+10" ) // true!isNaN( "0" ) // true!isNaN( "0xFF" ) // true!isNaN( "..
자바스크립트에서 REPLACE를 REPLACEALL 처럼 사용하기 자바스크립트에서 replaceAll 은 없다. 정규식을 이용하여 대상 스트링에서 모든 부분을 수정해 줄 수 있다. [replace 이용] ex) str.replace(“#”,””); -> #를 공백으로 변경한다. 하지만 첫번째 # 만 공백으로 변경하고 나머지는 변경이 되지 않는다. [정규식 이용해서 gi 로 감싸기] str.replace(/#/gi, “”); -> #를 감싼 따옴표를 슬래시로 대체하고 뒤에 gi 를 붙이면 replaceAll 과 같은 결과를 볼 수 있다. [정규식의 gi 설명] * g : 발생할 모든 pattern에 대한 전역 검색 * i : 대/소문자 구분 안함 * m: 여러 줄 검색 (참고) var str = "a1b1c1d1e"; str.replace(/1/gi,""); str = ..
특정 node 값 받아오기 String copyright_path = g_content_country_locale_url+"/jcr:content/footer/footer-copyright";Resource resources = resourceResolver.getResource(copyright_path);Node rootNode = resources.adaptTo(Node.class);String footer_copyright = rootNode.getProperty("text").getString();--- Result ----------------------------------------------------------------- PageManagerhttps://docs.adobe.com/docs/en/cq/5-6-1..
CQ/AEM Best Practices CQ/AEM Best PracticesStructure & Components:Make sure what you are building does not already exist: CQ is huge. There are 307 OSGi bundles and approximately 34 foundational components, 2 custom taglibs comprising 13 tags, a dozen or so standard JSP actions, with as many JSP Core tags and many other CQ components specific to add-ons. The chance the core of what you are building already exists in ..
string(문자열) 비교 ==, equals 의 차이 == 는 선언된 변수가 참조하는 메모리 주소를 비교함equals()는 선언된 변수의 값을 비교함 예시) 출력 String testVal : String testVal2 : String testVal3 = new String("test") : 비교 if(testVal == testVal2) : if(testVal == testVal3) : if(testVal.equals(testVal2)) : if(testVal.equals(testVal3)) : 실행해보면 true, false, true, true 순으로 결과 나올것이다. java에서는 선언된 변수의 값이 같으면 같은 메모리를 참조하기 때문에 == 를 사용해서 비교를 하면 true가 나오지만 new String()을 통해서 생성된 변수는 값이 같아도 새..