similar to: strsplit, keeping delimiters

Displaying 20 results from an estimated 10000 matches similar to: "strsplit, keeping delimiters"

2023 Apr 12
1
Split String in regex while Keeping Delimiter
On Wed, 12 Apr 2023 08:29:50 +0000 Emily Bakker <emilybakker at outlook.com> wrote: > Some example data: > ?leucocyten + gramnegatieve staven +++ grampositieve staven ++? > ?leucocyten ? grampositieve coccen +? > ? > I want to split the strings such that I get the following result: > c(?leucocyten +?, ??gramnegatieve staven +++?, > ??grampositieve staven ++?) >
2010 Aug 26
5
Quick GREP challenge
> grep("f[0-9]+=", "f1=5,f22=3,", value = T) [1] "f1=5,f22=3," How do I make the line output c("f1", "f22") instead? (Actually, c(1,22) would be even better). Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Quick-GREP-challenge-tp2339486p2339486.html Sent from the R help mailing list archive at Nabble.com.
2009 Nov 08
2
Extracting matched expressions
Hi all, Is there a tool in base R to extract matched expressions from a regular expression? i.e. given the regular expression "(.*?) (.*?) ([ehtr]{5})" is there a way to extract the character vector c("one", "two", "three") from the string "one two three" ? Thanks, Hadley -- http://had.co.nz/
2009 Jun 11
2
need help with strsplit function
Hi, if I have this string: "a.b.c.d" and I use this function: unlist(strsplit("a.b.c.d", "\\.")), I get this as my output: "a", "b", "c", and "d". Is there a way to just split on the first period so I obtain only two pieces like: "a" and "b.c.d"? Anyways, thanks in advance! -- View this message in context:
2008 Nov 11
2
strsplit (regex)
#how do I break these up into first two letters (RM), number, and then the last part #is there an easily accessible regex tutorial on the internet? v = (structure(1:122, .Label = c("RM215Temp", "RM215SpCond", "RM215DO.Conc", "RM215Depth", "RM215pH", "RM215ORP", "RM215Turbidity.", "RM215Battery", "RM215DO.",
2010 Apr 23
2
Problem with parsing a dataset - help earnestly sought
Dear fellow R-help members, I hope to seek your advice on how to parse/manage a dataset with hundreds of columns. Two examples of these columns, 'cancer.problems', and 'neuro.problems' are depicted below. Essentially, I need to parse this into a useful dataset, and unfortunately, I am not familiar with perl or any such language. data <- data.frame(id=c(1:10))
2008 Aug 12
2
perl expression question
I have a string such as fileName<-"Agg.20.20.20-all-01". All I want to do is pull the "20.20.20" and the "all" as strings. Obviously, they aren't always those values. The "20.20.20" can be "30.30.30" but it's always after the . which is next to the second g in Agg and it's always the same length. The all might not always be
2010 Jul 08
2
strsplit("dia ma", "\\b") splits characterwise
\b is word boundary. But, unexpectedly, strsplit("dia ma", "\\b") splits character by character. > strsplit("dia ma", "\\b") [[1]] [1] "d" "i" "a" " " "m" "a" > strsplit("dia ma", "\\b", perl=TRUE) [[1]] [1] "d" "i" "a" " "
2010 May 20
3
regex help: splitting strings with no separator
Greetings, I have a vector of values that are a word followed by a number, e.g., x = c("Apple12","HP42","Dell91"). The goal is to split this vector into two vectors such that the first vector contains just the words and the second contains just the numbers. I cannot use strsplit (or at least I do not know how) as there is no obvious separator. I can use sub to
2009 May 11
3
Searching within a ch. string
Hi all, is there any function to find some words in a character-string? For example suppose the string is : "gdfsa-sdhchc-88", now I want to find whether this string contains "sdhch". Is there any R function to do that? Regards, -- View this message in context: http://www.nabble.com/Searching-within-a-ch.-string-tp23484010p23484010.html Sent from the R help mailing list
2009 Jul 08
5
R regular expression to extract words with the query string.
Hi, Is there a way in R to get the string which matches the expression, where the expression is a substring of the parent string. Lets say, I have $i <- "transcript:ENST0000112334 pid:ENSP000012345" What I need is the string "pid:ENSP000012345" from $i using the query "ENSP". Appreciate your comments. Praveen Surendran School of Medicine and
2008 Apr 09
11
Number of words in a string
Hi R, A quick question: How do we find the number of words in a string? Example: C="Have a nice day" And the number of words should be 4. any built in function or?... Thanks, Shubha Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com This e-mail may contain
2007 Sep 25
5
extracting data using strings as delimiters
Dear List, I have an ascii text file with data I'd like to extract. Example: Year Built: 1873 Gross Building Area: 578 sq ft Total Rooms: 6 Living Area: 578 sq ft There is a lot of data I'd like to ignore in each record, so I'm hoping there is a way to use strings as delimiters to get the data I want (e.g. tell R to take data between "Built:" and "Gross" -
2008 Jan 18
1
Regex magic anyone?
Hi again, how to elegantly split s <- "ABCDEFGT(P)HIJK" into "A" "B" "C" "D" "E" "F" "G" "T(P)" "H" "I" "J" "K" (independently of which letters 'T' or 'P' actually represent ...). Please jumstart my regexing, Joh
2007 Aug 23
2
Splitting strings
I'm having a Thursday morning mental block, any suggestions on the following would be most appreciated... I have (as an example) surgery = c("d48", "d67", "dnc37", "a75", "d10", "a78", "d31", "d55", "d1") before each number part the possibilities are c("a", "d",
2011 Feb 04
3
lapply, strsplit, and list elements
Hi there, I have a problem about lapply, strsplit, and accessing list elements, which I don't understand or cannot solve: I have e.g. a character vector with three elements: x = c("349/077,349/074,349/100,349/117", "340/384.2,340/513,367/139,455/128,D13/168", "600/437,128/903,128/904") The task I want to perform, is to generate a list,
2009 Apr 10
3
Determine the Length of the Longest Word in a String
Hi Everyone, I'm new to programming R and have accomplished my goal, but feel that there is probably a more efficient way of coding this. I'd appreciate any guidance that a more advanced programmer can provide. My goal -- I would like to find the length of the longest word in a string containing many words separated by spaces. How I did it -- I was able to find the length of the
2008 Jul 04
4
Re ad in a file - produce independent vectors
Is there a way of reading in a file in a way that each line becomes a vector: for example: meals.txt breakfast bacon eggs sausage lunch sandwich apple marsbar crisps dinner chicken rice custard pie I want to read in this file and end up with 3 different vectors, one called breakfast which contains "bacon", "eggs", sausage" One called
2008 Nov 02
5
R newbie: how to replace string/regular expression
Hello; I am a R newbie and would like to know correct and efficient method for doing string replacement. I have a large data set, where I want to replace character "M", "b", and "K" (currency in Million, Billion and K) to millions. That is 209.7B with (209.7 * 10e6) and 100.00K with (100.00 *1/100) and etc.. d <- c("120.0M", "11.01m",
2010 Jul 02
3
Good Package(s) for String and URL processing?
Are there packages that allow improved String and URL processing? E.g. extract parts of a URLs such as sub-domains, top-level domain, protocols (e.g. https, http, ftp), file type based on endings, check if a URL is valid or not, etc... I am currently only using split and paste. Are there better and more efficient ways to handle strings e.g. finding sub-strings or to do pattern matching? What