'split'에 해당되는 글 2건

  1. 2016.03.28 perl split
  2. 2016.01.12 1월 첫째주 정리

perl split

카테고리 없음 2016. 3. 28. 19:00

split을 하면 split의 기준이 되는 글자를 제외하고 나머지 부분이 앞 뒤로 배열 형태로 리턴된다. 


형식

my @arr = split /test/ , $str;


Posted by 썬,더 호글
,

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 썬,더 호글
,