1월 첫째주 정리

배운 것 2016. 1. 12. 23:48

## perl split 

```pl

my @word = split /:/, $string;

```


- split 함수가 소괄호 안에 묶여있지 않고, 스플릿 할 대상을 뒤에 방치하는게 특징. 문법이 특이하다. 스플릿을 하고 나면 언제나 그렇듯 배열로 받게 된다. 


##일정한 형식의 python string을 정규표현식 없이 잘라내는 법

string = "0123456789"

print s[0:4]  >> 01234

print string[5:8] >>5678

print string[5:] >>56789

print s[:9] >> 0123456789

print string[-1] >>> 9

print s[-7 : -3] >>> 34567


##python index

str = "12345678"

str2="345"

print str.index(str2) >> 2


인자로 넣은 스트링이 존재하는 첫번째 문자의 위치값이 반환된다. 


##grep -B 20 "test" filename

파일 내에 test라는 글자가 있는 라인으로부터 -Before 20줄을 출력한다. 




'배운 것' 카테고리의 다른 글

command pattern  (0) 2016.01.28
log4j error  (0) 2016.01.26
intellij 에서 maven profile 선택해서 실행하기  (0) 2016.01.19
logback.xml 에서 에러로그 분리  (0) 2016.01.18
perl chomp  (0) 2016.01.08
Posted by 썬,더 호글
,

perl chomp

배운 것 2016. 1. 8. 10:52

perl chomp, chop 함수 (개행문자 삭제)


line에 \n이 붙어있을 경우 삭제해준다.

'배운 것' 카테고리의 다른 글

command pattern  (0) 2016.01.28
log4j error  (0) 2016.01.26
intellij 에서 maven profile 선택해서 실행하기  (0) 2016.01.19
logback.xml 에서 에러로그 분리  (0) 2016.01.18
1월 첫째주 정리  (0) 2016.01.12
Posted by 썬,더 호글
,