사용자 도구

사이트 도구


javascript:regexp

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
javascript:regexp [2021/10/01 14:20] – 바깥 편집 127.0.0.1javascript:regexp [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +===== Javascript RegExp =====
  
 +<code jsvascript>
 +function funRegComma(param){
 +var num = '' +param;
 +var reg = /(^[+-]?\d+)(\d{3})/;
 +while(reg.test(num)){
 +num = num.replace(reg,'$1' + ',' + '$2');
 +}
 +return num;
 +}
 +==== Password ====
 +비밀번호 체크하기 위한 RegExp
 +<code javascript>
 +var strongRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
 +</code>
 +^RegEx ^Description^
 +|''^'' |The password string will start this way|
 +|(?=.*[a-z]) |The string must contain at least 1 lowercase alphabetical character|
 +|(?=.*[A-Z]) |The string must contain at least 1 uppercase alphabetical character|
 +|(?=.*[0-9]) |The string must contain at least 1 numeric character|
 +|(?=.[!@#\$%\''^''&]) |The string must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict|
 +|(?=.{8,}) |The string must be eight characters or longer|
 +| | |
 +
 +==== 전화번호 ====
 + <h5:Action type="SCRIPT" name="checkPhone">
 + var regExpPhone = /^[0-9|-]+$/;
 + if( !regExpPhone.test($("#phone_no").val()) ){
 + var s = $("#phone_no").val().replace(/[^\d-]/g, '');
 + $("#phone_no").val(s);
 + }
 + </h5:Action>
 +
 +
 + <h5:TextInput id="phone_no" bindingColumn="phone_no" width="100px" maskText="PhoneNo" maxLength="20">
 + <h5:ElementEvents>
 + <h5:OnChangeEvent actionName="checkPhone"></h5:OnChangeEvent>
 + </h5:ElementEvents>
 + </h5:TextInput>
 +
 +
 + <h5:Action name="download" type="SCRIPT">
 + mySheet1.SetColHidden("detail",true);//type="Html" 숨기기.
 +
 + var excelFileName = ""+ "선택근무제신청_"+getStdDate()+".xls";
 + var downcol = makeHiddenSkipCol( mySheet1 );
 + var params = { DownCols: downcol, FileName: excelFileName, SheetName: "Sheet", Merge:1, SheetDesign: 1 };
 + mySheet1.Down2Excel(params);
 +
 + mySheet1.SetColHidden("detail",false);//type="Html" 보이기.
 + </h5:Action>
 +==== 숫자의 콤마표현 ====
 +<code javascript>
 +function numberWithCommas(x) {
 +//sumVal = sumVal.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); //IE에서 오류
 +    return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",");
 +}
 +</code>
 +==== 시분표현 ====
 +<code javascript>
 + //시분포멧 (12:00) 체크
 + var timeFormat = /^([01][0-9]|2[0-3]):([0-5][0-9])$/;
 + //숫자 네자리(0000) 체크
 + var timeFormat2 = /^([01][0-9]|2[0-3])([0-5][0-9])$/;
 +</code>