problem with regular expression I have a dataframe in R containing  a variable for programming languages. This is extracted from a multiple choice questionnaire in a survey. As a result, any programming language may fall into the beginning, middle or end of the whole string.
I added a binary variable for any programming language. Here is a sample of my data:

language &lt;- c(
"Ruby, Assembly, R, Go, Rust",
"Java, Javascript, Ruby, SQL",
"Java, Ruby",
"C, C++",
"PHP, Javascript, Ruby, Assembly, Swift, R, Matlab, Go, Haskell",
"R",
"Perl, Javascript, R",
"Javascript, Ruby, Bash",
"Python, PHP, Javascript",
"Java",
"Java, C"
 )

df &lt;-as.data.frame(language,stringsAsFactors = FALSE)
df$python      &lt;- 0
df$java        &lt;- 0
df$c           &lt;- 0
df$r           &lt;- 0
df$d           &lt;- 0

for(trow in (1:nrow(data)))
{if (length (grep(pattern="Python",x=df[trow,"language"]))  &gt; 0)    {df[trow,"python"] &lt;- 1}}


I have problem with one-word languages such as C, R, D and Java . I made the variables for C#, C++ , Javascript, Ruby and others using the for loop but  I have problems with these four. What regular expression can I use so that it covers Java but not Javascript (in the beginning, middle and end of the string) and covers R but not Ruby and so on? Any other solution for making the binary variables are also welcome.
You could do

reshape2::recast(
  data = setNames(strsplit(language, ", ", T), language), 
  formula = L1~value, 
  fun.aggregate = length
)
#                                                                L1 Assembly Go R Ruby Rust Java Javascript SQL C C++ Haskell Matlab PHP Swift Perl Bash Python
# 1                                                          C, C++        0  0 0    0    0    0          0   0 1   1       0      0   0     0    0    0      0
# 2                                                            Java        0  0 0    0    0    1          0   0 0   0       0      0   0     0    0    0      0
# 3                                                         Java, C        0  0 0    0    0    1          0   0 1   0       0      0   0     0    0    0      0
# 4                                     Java, Javascript, Ruby, SQL        0  0 0    1    0    1          1   1 0   0       0      0   0     0    0    0      0
# 5                                                      Java, Ruby        0  0 0    1    0    1          0   0 0   0       0      0   0     0    0    0      0
# 6                                          Javascript, Ruby, Bash        0  0 0    1    0    0          1   0 0   0       0      0   0     0    0    1      0
# 7                                             Perl, Javascript, R        0  0 1    0    0    0          1   0 0   0       0      0   0     0    1    0      0
# 8  PHP, Javascript, Ruby, Assembly, Swift, R, Matlab, Go, Haskell        1  1 1    1    0    0          1   0 0   0       1      1   1     1    0    0      0
# 9                                         Python, PHP, Javascript        0  0 0    0    0    0          1   0 0   0       0      0   1     0    0    0      1
# 10                                                              R        0  0 1    0    0    0          0   0 0   0       0      0   0     0    0    0      0
# 11                                    Ruby, Assembly, R, Go, Rust        1  1 1    1    1    0          0   0 0   0       0      0   0     0    0    0      0