Hi, May be this helps: strsplit(sub("(.*)(\\|.*)","\\1 \\2",test), " ")[[1]] #[1] "comp99810_c0_seq1" "|m.8409" sub("(.*)\\|.*","\\1",test) #[1] "comp99810_c0_seq1" sub(".*(\\|.*)","\\1",test) #[1] "|m.8409" A.K. Hi Could some one help me regular expression for this. I am really struggling. Basically i want to write a regular expression to separate the string into two sub strings. For example in the example i want to separate the full string into "comp99810_c0_seq1" and "|m.8409". test <- "comp99810_c0_seq1|m.8409" c1 <- sub("([A-Za-z1-9])(\\|)(m.\\d+)", "\\1", test) c2 <- sub("([A-Za-z1-9])(\\|)(m.\\d+)", "\\2\\3", test) I was able to get c1 to work but not c2. Can somebody help me.... Thanks Upendra