1 / 1
" String"으로 검색하여,
4 건의 기사가 검색 되었습니다.
-
2020-01-19camel case로 된 분자열을 snake case로 변환하는 경우 사용할 수 있는 함수이다.대문자 전환은 옵션으로 사용underscore대신 hyphen을 사용하는 경우는 함수 내의 문자열을 수정하여 사용하던지 대응되는 함수를 만들어 사용/**** Camel case convert to Snake case** parameter: s(convert string), u(optional: uppercase)**/function camel2Snake( s, u ) { let r = ''; if(s!==undefined && s!==null) { let sp = s.split(/(?=[A-Z])/); if(u!==undefined && u!==null && u) { r = sp.join('_').toUpperCase(); } else { r = sp.join('_').toLowerCase(); } } return r;}camel2Snake('asdjaskSsdjsSsada');>> "asdjask_ssdjs_ssada"camel2Snake('asdjaskSsdjsSsada', true );>> "ASDJASK_SSDJS_SSADA"
-
2015-04-27구분자로 여러내용을 모아 저장하는 문자열은 일반적으로 어프리케이션 단에서 처리를 하는데,서버단에서 처리가 필요한 경우 사용 할 수 있는 함수 입니다.Syntax :fc_split_str( [문자열], [구분자], [순서] ) 사용예제 declare @c varchar(250)select @c = '000,0005,2011,1,211,000,000'SELECT * FROM fc_split_str(@c,',', 4) ----------------------------------------------------/*prog by inkyung kim*/create function fc_split_str( @cText varchar(2000), -- 문자열 @cDelimiter varchar(1), -- 구분자 @iPosString int) returns @split_temp table ( value varchar(2000) ) as begin declare @iStartPos int, @iDelimiterPos int, @iCount int declare @tmpvar varchar(1000) -- 분리된 문자열 임시 저장변수 set @iCount = 0 -- 순서 set @iStartPos = 1 -- 구분문자 검색을 시작할 위치 set @iDelimiterPos = 1 -- 구분문자 위치 while (@iDelimiterPos > 0) begin set @iCount = @iCount + 1 set @iDelimiterPos = charindex( @cDelimiter, @cText, @iStartPos ) if @iDelimiterPos = 0 set @tmpvar = right( @cText, len(@cText)-@iStartPos+1 ) else set @tmpvar = substring( @cText, @iStartPos, @iDelimiterPos-@iStartPos ) if ( (len(@tmpvar)>0) and (@iPosString=@iCount) ) insert into @split_temp values( @tmpvar ) set @iStartPos = @iDelimiterPos +1 end return end----------------------------------------------
-
2014-05-08랜덤키를 만들어야 하는 경우에 이용가능하다.랜덤으로 만들어진 값을 숫자(0~9)와 알파벳으로 표현하는 36진수로 변환 하여 랜덤키를 만듭니다.<%response.write KeyGen32()&".txt"function KeyGen32()dim iRnd, Responsedim cRnd, iRandomizecRnd = ""for i = 1 to 8iRnd = Int(( 999999 - 1 + 1) * Rnd + 1) '=== 6 digitscRnd = cRnd & Dec6to36( FillZero(iRnd,6) )nextKeyGen32 = cRndend functionfunction Dec6to36(num)dim d1,d2,d3,d4,r1,r2d1 = Int( num / 46656 )r1 = ( num mod 46656 )d2 = Int( r1 / 1296 )r2 = ( r1 mod 1296 )d3 = Int( r2 / 36 )d4 = ( r2 mod 36 )Dec6to36 = Convert10to36(d1) & Convert10to36(d2) & Convert10to36(d3) & Convert10to36(d4)end function'== 10진수를 36진수로 변환function Convert10to36( i )if ( i < 10 ) thenConvert10to36 = ielseConvert10to36 = chr(55+i)end ifend functionfunction FillZero( cString, iLength )FillZero = FillString( cString, iLength, "0" )end functionfunction FillString( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillString = ( String( iLength -Len( cString ), cFillString ) & cString )elseFillString = cStringend ifend function%>
-
2014-04-30문자 채우기문자(숫자)를 출력하면서 특정문자를 결합하는 경우에 사용한다 - 숫자 "1"을 네자리의 Numneric(빈자리가 "0"로 채워진) 4자리로 변환 하는 경우 1 => "0001" - 좌우측으로 여백문자처리의 경우 • FillString(): 특정문자 채우기 • FillZero(): "0" 문자 채우기 • FillSpace(): 스페이스 채우기문자 자르기mid() 함수를 이용하여 문자를 자르는 경우 2byte 문자도 자릿수에 상관 없이 1문자로 처리되기 떄문에 의도한 것보다 길게 나오는 경우가 많은데 2byte 문자를 감안하여 해당 자릿수에서 문자를 잘라 반환 한다 - 게시판의 제목 등 길어질 수 있는 내용을 좁은 구역에 출력시 유효 - 지정길이보다 긴 경우 +More 사용 • HLeftB(): 2byte 문자 자르기 • HLeftBMore(): 2byte 문자 자른 후 길이가 넘는 경우 "…" 문자 추가<%'===============================================' >> Fill Stuff functions'' FillZero( cString, iLength )' FillSpace( cString, iLength )' FillString( cString, iLength, cFillString )''===============================================function FillZero( cString, iLength )FillZero = FillString( cString, iLength, "0" )end functionfunction FillSpace( cString, iLength )FillSpace = FillString( cString, iLength, " " )end functionfunction FillSpaceRight( cString, iLength )FillSpaceRight = FillStringRight( cString, iLength, " " )end functionfunction FillString( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillString = ( String( iLength -Len( cString ), cFillString ) & cString )elseFillString = cStringend ifend functionfunction FillStringRight( cString, iLength, cFillString )if( iLength >Len(cString) ) thenFillStringRight = ( cString & String( iLength -Len( cString ), cFillString ) )elseFillStringRight = cStringend ifend functionfunction HLeftB( cString, iLen ) dim i, c, a, bdim cReturnb = 0cReturn = ""if not IsNull(cString) thenfor i = 1 to Len(cString)c = mid(cString,i,1)a = asc(c)cReturn = cReturn&cif (a>255 or a<0) thenb = b+2elseb = b+1end ifif (iLen=<b) thenexit forend ifnextend ifHLeftB = cReturnend functionfunction HLeftBMore( cString, iLen ) dim cc = HLeftB( cString, iLen ) if (cString>c) thenc = c &"…"end ifHLeftBMore = cend function%>
1
