Extract specific data from text

andreas

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?

G5W

You can get this with sub and a regular expression.

NewColumn = sub(".*\\b(Sone\\s+\\d+).*", "\\1", String)
NewColumn
[1] "Sone 33"

Some detail on the RegEx

The part in the middle 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.

edited at
0

Comments

0 comments
Login to comment

Related