'java'에 해당되는 글 2건

  1. 2014.04.02 Ubuntu에 Oracle Java7, Tomcat7 설치하기
  2. 2012.05.29 PCRE 정규표현식 기본기
우분투2014. 4. 2. 23:56

1. Java 설치

     1) 우분투에 오라클jdk를 설치하기 위해서는 아래 명령어를 입력하면 자동으로 설치가 됩니다.

sudo apt-get install oracle-jdk7-installer 

제거할 경우 : sudo apt-get remove 패키지명

 

     2) 패키지를 찾을수 없다고 나올경우

         아래 명령어를 입력하여 패키지 목록을 업데이트 합니다.

sudo apt-get install python-software-properties

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update

         업데이트가 완료되었으면 설치가 가능합니다.  

 

2. Java 설치 확인

java -version


java version "1.7.0_51"

Java(TM) SE Runtime Environment (build 1.7.0_51-b13)

Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

    위와 유사한 메시지를 출력해주면 설치가 완료상태를 확인할 수 있습니다.

 

3. Tomcat7 설치

sudo apt-get install tomcat7

 

4. Tomcat 버전 확인

sh /usr/share/tomcat7/bin/version.sh

 

Using CATALINA_BASE:   /usr/share/tomcat7

Using CATALINA_HOME:   /usr/share/tomcat7

Using CATALINA_TMPDIR: /usr/share/tomcat7/temp

Using JRE_HOME:        /usr

Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

Server version: Apache Tomcat/7.0.42

Server built:   Aug 1 2013 01:42:03

Server number:  7.0.42.0

OS Name:        Linux

OS Version:     3.11.0-12-generic

Architecture:   amd64

JVM Version:    1.7.0_51-b13

JVM Vendor:     Oracle Corporation

ubuntu@ip-172-31-22-219:/usr/share/tomcat7/bin$ cd ~

ubuntu@ip-172-31-22-219:~$ sh /usr/share/tomcat7/bin/version.sh

Using CATALINA_BASE:   /usr/share/tomcat7

Using CATALINA_HOME:   /usr/share/tomcat7

Using CATALINA_TMPDIR: /usr/share/tomcat7/temp

Using JRE_HOME:        /usr

Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

Server version: Apache Tomcat/7.0.42

Server built:   Aug 1 2013 01:42:03

Server number:  7.0.42.0

OS Name:        Linux

OS Version:     3.11.0-12-generic

Architecture:   amd64

JVM Version:    1.7.0_51-b13

JVM Vendor:     Oracle Corporation

    위와 유사한 메시지를 출력해주면 설치가 완료상태를 확인할 수 있습니다.

 

5. Tomcat 서비스 구동

sudo service tomcat7 start

 

6. 웹 브라우져로 구동 확인

 

 

Posted by 다오나무
영삼이의 IT정보2012. 5. 29. 13:05

PCRE 정규표현식 기본기


http://kr2.php.net/manual/en/ref.pcre.php
http://kr2.php.net/manual/en/reference.pcre.pattern.syntax.php
http://kr2.php.net/manual/en/reference.pcre.pattern.modifiers.php

위 링크의 내용을 바탕으로 기본을 설명합니다.

1. \ : 정규표현식에 사용되는 기호를 문자로써 사용하기 위해 탈출(escape) 시키는 문자.
<?php
preg_match('/\//', '---/---', $matches);
echo $matches[0];
?>
/

2. . : 아무거나 한 글자를 의미 (UTF-8 에서는 글자단위 그 외에는 byte 단위) (개행문자 제외)
3. ^ : 시작을 의미
<?php
echo preg_replace('/^./', '', 'abcd');
?>
bcd

4. $ : 끝을 의미
<?php
echo preg_replace('/.$/', '', 'abcd');
?>
abc

5. * : 앞의 기호의 반복을 의미 없어도 참
6. + : 앞의 기호의 반복을 의미 없으면 거짓
7. [] : [] 안의 내용 중 한글자를 의미 (- 로 구간설정 가능)
8. \d : [0-9] 를 의미
<?php
if(!preg_match('/^[1-9]\d*$/', $_GET['no'])) {
    echo '1 부터 시작하는 수를 적으셔';
    exit;
}
if(!preg_match('/^[a-z]+$/', $_GET['text'])) {
    echo '영문 소문자만 적으셔';
}
?>

9. \s : 공백문자를 의미 (탭 포함)
10. \t : 탭을 의미
11. \r : 개행문자 0x0d 를 의미
12. \n : 개행문자 0x0a 를 의미
<?php
$text = <<<TEXT
가나다 김삼순
킹왕짱     어쭈구리

abcd
TEXT;
print_r(preg_split('/[\s\r\n]+/', $text));
$text = <<<TEXT

?>
Array
(
     [0] => 가나다
     [1] => 김삼순
     [2] => 킹왕짱
     [3] => 어쭈구리
     [4] => abcd
)
<?php
$text = <<<TEXT
이름\t진\t선\t미
김태희\t80\t90\t100
송혜교\t100\t100\t98
TEXT;
$rows = preg_split('/[\r\n]+/', $text);
foreach($rows as $row) {
    $cols[] = preg_split('/\t/', trim($row));
}
print_r($cols);
?>
Array
(
     [0] => Array
         (
             [0] => 이름
             [1] => 진
             [2] => 선
             [3] => 미
         )

     [1] => Array
         (
             [0] => 김태희
             [1] => 80
             [2] => 90
             [3] => 100
         )

     [2] => Array
         (
             [0] => 송혜교
             [1] => 100
             [2] => 100
             [3] => 98
         )

)

13. ? : 존재유무 ()괄호와 함께 쓸 수 있다.
<?php
$text = <<<TEXT
<input type="text" name=asdf value="asdf" />
TEXT;
$cnt = preg_match_all('@([a-z]+)\s*=\s*"?([a-z]+)@', $text, $matches);
unset($matches[0]);
print_r($matches);
?>
Array
(
     [1] => Array
         (
             [0] => type
             [1] => name
             [2] => value
         )

     [2] => Array
         (
             [0] => text
             [1] => asdf
             [2] => asdf
         )

)
<?php
$text = <<<TEXT
<p>asdf <strong>zxcv</strong></p>
<p><strong>zxcv</strong> zxcv zxcv</p>
TEXT;
echo preg_replace('@(<strong>)?zxcv(</strong>)?@', 'qwer', $text);
?>
<p>asdf qwer</p>
<p>qwer qwer qwer</p>

14. .*?, .+? : 매치범위를 최소화 한다.
<?php
$text = <<<TEXT
<a href="a">a</a><a href="b">b</a><a href="c">c</a>
TEXT;
preg_match('@<a .*>@', $text, $matches);
echo $matches[0]."\n";
preg_match('@<a .*?>@', $text, $matches);
echo $matches[0]."\n";
?>
<a href="a">a</a><a href="b">b</a><a href="c">c</a>
<a href="a">

Posted by 다오나무