아주 간단한 질문입니다. 몇 번의 반복을 시도했지만 여전히 올바른 대답을 얻지 못했습니다. 어쩌면 "grep"이 올바른 명령이 아니거나 제 이해가 완전히 끝났을 수 있습니다. "차 목표"나는에 대한 일치 검색을 시도하고정확한 문자열 일치
"Part 2.2 are Secondary objectives of this study".
:
나는 문자열을 가지고있다. 나는 여기서 "fixed = TRUE"를 사용할 수 있다고 생각했지만, 둘 다 일치한다.
> str5 = "Part 2.2 are Secondary objectives of this study"
> line<-grep("Secondary objectives",str5,fixed=TRUE)
> line
[1] 1
> str5 = "Part 2.2 are Secondary objectives of this study"
> line<-grep("Secondary objective",str5,fixed=TRUE)
> line
[1] 1
나는 "grep"이 정확히 수행하고 있다고 이해합니다. 기술적으로 원래 문자열에있는 "Secondary objective"문자열을 검색합니다. 그러나 내 이해는 "fixed = TRUE"명령을 사용하여 정확한 일치를 수행 할 수 있습니다. 그러나 분명히 착각했습니다.
"fixed = TRUE"인 "grep"이 완전 일치 명령이 아닌 경우, ?. 일 "str_match는"중 하나가 작동하지 않았다 을 내 패턴 인 경우 : "보조 목적은"이 반환해야 내 패턴이 "차 목표"이 "정수 (0)" 하지만, 그것은 1
를 반환해야 감사합니다. - simak
업데이트 : 아래의 Arun의 제안을 시도해보십시오. 입니다.
str5 = "Part 2.2 are Secondary objectives of this study"
> grep("(Secondary objectives)(?![[:alpha:]])",str5, perl=TRUE)
[1] 1
> grep("(Secondary objective)(?![[:alpha:]])",str5, perl=TRUE)
integer(0)
STR5 = 그렙 "부품 2.2 본 연구 보조 목적이다"("(팻) ([: 알파 :]?!)」, STR5 펄 = TRUE) 정수 (0) 내가 생각할 수
However when I did this:
> str5 = "Part 2.2 are Secondary objectives of this study"
> pat <- "Secondary objectives"
> grep("(pat)(?![[:alpha:]])",str5, perl=TRUE)
integer(0)
Thought I can call "pat" inside "grep". Is that incorrect? Thanks!
, 내가 어떻게 당신을 말했다 : '팻 <- paste0 (")", "(" "차 목표를" "?! ([[: 알파 :]])")' 'grep (pat, str5, perl = TRUE)'을 시도하십시오. – Arun
그래도 시도해 보았습니다. ..... 나 didnt 일 ..... – BRZ
당신은 무엇이 작동하지 않는 것을 의미합니까? 'Secondary objective'는'integer (0)'을,'Secondary objectives'는'1'을줍니다. 나에게 좋을 것 같다! – Arun