[R] String Matching
Ista Zahn
istazahn at gmail.com
Wed Aug 12 21:40:03 CEST 2015
Hi Kevin,
It's not totally clear to me what the desired output is.
grep(searchString, matchString, ignore.case=FALSE)
told you that searchString is in the first element of matchString.
Isn't that what you want to know? If not, perhaps you can be more
specific about what the desired result is.
Best,
Ista
On Wed, Aug 12, 2015 at 11:51 AM, Kevin Kowitski <k.kowitski at icloud.com> wrote:
> Hey everyone,
>
> I have been having an issue trying to find a specific string of text in a
> log of system messages. I have tried to use pmatch, match, and some regular
> expressions but all to no avail.
>
> I have a matrix / data.frame (either one, the file outputs a tens of
> thousands of rows with a single column) of strings in the following format
> with different items after INFO:
> "09:11:57.259 - Assay File Processing Thread - INFO - SolenoidCycleMessage:
> Addr = 0x03 "
>
> as an example I would like to match "SolenoidCycleMessage"
> searchString<-"SolenoidCycleMessage"
> matchString<-"09:11:57.259 - Assay File Processing Thread - INFO -
> SolenoidCycleMessage: Addr = 0x03"
>
>> pmatch(searchString, matchString)
>
> [1] NA
>
>> match(searchString, matchString)
>
> [1] NA
>>
>> match(matchString, searchString)
>
> [1] NA
>>
>> grep(searchString, matchString, ignore.case=FALSE)
>
> [1] 1
>>
>> df<-as.data.frame(c(matchString, string1, string2))
>> df
>
> c(matchString,
> string1, string2)
> 1 09:11:57.259 - Assay File Processing Thread - INFO - SolenoidCycleMessage:
> Addr = 0x03
> 2
> 23:12:43.22 - Test
> 3
> test
>>
>> grep(searchString, df, ignore.case=FALSE)
>
> integer(0)
>
>> grep(searchString, c(matchString, string1, string2), ignore.case=FALSE)
>
> [1] 1
>
> Doe anyone have some input that could help?
>
> Thanks,
> Kevin
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list