Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am looking for a regular expression that matches R33 and r34E. I tried (R|r)[0-9]{2}+[A-Z]{1} but got an error.
/[rR][0-9]{2}[A-Z]?/
It is an invalid Regular Expression. If you want to have 2 or more digits, {2}+ won't work, you should use {2,}.
(R|r)[0-9]{2,}[A-Z]?
[0-9]{2}+
That plus sign looks wrong. If you take that out:
(R|r)[0-9]{2}[A-Z]?
Appears to do what you want (upper- or lowercase R, two digits, optionally any uppercase letter).
Try ^(R|r)[0-9]{2}$|^(R|r)[0-9]{2}[A-Z]{1}$
Your regex is invalid.
You can use {2} or + on an expression, but not both.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
how to add parentheses between numbers? I know how to add dashes, are they doing the same way? like 123456789 to (123)456789 in R programming?
sub("(\\d{3})", "(\\1)", 123456789)
[1] "(123)456789"
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm interested to pull out instances where initials are used in my text data, as they are almost always two capital letters, is there a simple way to look for this text pattern using Grep in R?
If we need to match two upper case letters from the start (^) of the string, use grepl on the column concerned to return a logical expression within subset to subset the rows
subset(df1, grepl("^[A-Z]{2}", col1))
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Currently in R, with data.table, I have the following column:
jamesmann#yahoo.com
bill.free#yahoo.com
computer.trader#yahoo.com
j*****n#gmail.com
which are factors. I would like to parse the above so that I can get the first and last letters of the username before the # symbol.
So for the above I'd like to get:
jn
be
cr
jn
I deal with some asterisked usernames so I added it in too. Is there a simple way to do this? Any thoughts would be greatly appreciated.
Match the following pattern to the strings and replace it with the capture groups:
sub("(.).*(.)#.*", "\\1\\2", s)
## [1] "jn" "be" "cr" "jn"
Note
The input strings in reproducible form is:
s <- c("jamesmann#yahoo.com", "bill.free#yahoo.com", "computer.trader#yahoo.com",
"j*****n#gmail.com")
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am trying to write this (SAS) comand in R. x is a variable with this specific format: j61915035t
x1 = trim(upcase(substr(x,1,1)));
I really appreciate what you are doing in this site!
You want to remove leading/trailing blanks from a character string that is the uppercase first letter of the string x. So this should do it.
library(stringr)
x1 = str_trim(str_to_upper(str_sub(x,1,1)))
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
According to this documentation, there is nothing stating if the delimiter can be multiple characters or a string. Can someone confirm if it is possible to use a string as the delimiter? Perhaps something like "-----"?
http://www.postfix.org/postconf.5.html#recipient_delimiter
After reading the source code it looks like that variable eventually gets used as an int. So the delimiter can only be a single character.
However, since Postfix 2.11, there can be multiple delimiters:
When the recipient_delimiter set contains multiple characters (Postfix 2.11 and later), a user name or .forward file name is separated from its extension by the first character that matches the recipient_delimiter set.
Source: http://www.postfix.org/postconf.5.html#recipient_delimiter