Hi there, I have to extract some relevant portion from a defined string,
which is a mix of numeric and character. However this has following
sequence:

 

Some String - Some numerical - "c/C" (or "p/P") - then again some set of
numbers.

 

Examples of such string is "fdahsdfcha163517253c463278643" or
"fdahsdfcha163517253C463278643" or "fdahsdfcha163517253P463278643",
"fdahsdfcha163517253p463278643" etc.

 

I have tried using latest stringr package to accomplice that. Here is my
try:

 

> library(stringr)

> str_extract("fdahsdfcha163517253c463278643", "[c]")

[1] "c"

 

But it seems that, above code fetching "c" from "fdahsdfcha" only. My goal
is to understand what is there between above 2 set of numbers, "C/c/P/p"?
Can somebody help me how to do that? I would like to use stringr syntax
because, I am already using lot of other functions from that. Therefore if I
can do it using that package then it would be good in terms of consistency.

 

Thanks for your help.

 

 

 

 


	[[alternative HTML version deleted]]

