Split a string by a plus sign (+) character
Use
strsplit("(1)+(2)", "\\+")
or
strsplit("(1)+(2)", "+", fixed = TRUE)
The idea of using strsplit("(1)+(2)", "+")
doesn't work since unless specified otherwise, the split
argument is a regular expression, and the +
character is special in regex. Other characters that also need extra care are
?
*
.
^
$
\
|
{
}
[
]
(
)
Below Worked for me:
import re
re.split('\\+', 'ABC+CDE')
Output:
['ABC', 'CDE']