I have a single column with many rows with following geographical information:
Ø228818, N6575807 Sone 33 (±500m) UTM(WGS 84)
These are all merged in a single column, only separated with "," and " " . I need to extract the "Sone XX" into an own column, but i haven`t found any suitable commands for this. Any suggestions?
You can get this with sub
and a regular expression.
NewColumn = sub(".*\\b(Sone\\s+\\d+).*", "\\1", String)
NewColumn
[1] "Sone 33"
Sone\\s+\\d+
is what you want.Sone
is the literal string. \\s+
matches one or more blanks. \\d+
matches one or more digits, 0-9. That group is enclosed in parentheses so that the result is stored for later use. The pattern is preceded and followed by \\.*
to match everything else.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments