Skip to content

How can I parse this string to extract just the number 11?

1 message · Rui Barradas

#
Hello,

Sorry, but I don't understand, there's nothing specific in the search 
pattern, it searches for the negation of digits and replaces them for "".

string = "\t\t\t\t\t<span class=\"compliment-count profile\">11</span>"
string = c(string, "\t\t\t\t\t<span class=\"compliment-count 
profile\">1234</span>")
string = c(string, "\t\t\t\t\t<span class=\"compliment-count 
profile\">9876543210</span>")

gsub("[^[:digit:]]", "", string)
[1] "11"         "1234"       "9876543210"

Have you tried with other numbers?

Rui Barradas

Em 31-07-2012 21:25, Shelby McIntyre escreveu: