我是新手,我想以数组格式从此字符串中提取所有IP地址
## take your original `sparsed` data frame, where `User` is numeric
sparsed$User <- as.numeric(
factor(as.character(sparsed$User),
levels = sort(unique(sparsed$User)))
)
## no need to do anything with `Movie` at it's already contiguous numeric from 1
sparse <- sparseMatrix(i = sparsed$Movie,
j = sparsed$User,
x = sparsed$Rating)
#8 x 15 sparse Matrix of class "dgCMatrix"
#
#[1,] 3 . . . 1 . . . 2 . . . . . .
#[2,] . . . . . 4 . . 5 . . . . 3 .
#[3,] 3 2 . . . . . 4 . . 2 . . 5 .
#[4,] . . . 5 . . . . 3 . . . . . .
#[5,] 3 . 4 5 . . 1 . . . . . 3 2 4
#[6,] . . . . 2 . . . . . . 3 . . .
#[7,] . . . . . . . . 1 2 . . . . .
#[8,] 1 . . . . . . . . . . . . . .
当我跳过一步时,我将获得所有IP,这意味着当我使用$ copy [2]时我将获得第二个IP。我想提取所有ip而不跳过该步骤。
答案 0 :(得分:1)
$str = "ghg shjsja 192.168.1.2 hbkjNKKSJKKN HKJCBKJLKKL 12.15.14.45 " & _
"KJBKJABCKBNDKQ djfsjdkfhnwk kjwenfkjdsnf knfflksnf KHBKJABCKJQDH " & _
"1.1.1.1 2.2.2.2"
$copy = StringRegExp($str, "((?:\d{1,3}\.){3}\d{1,3})", 3)
For $i = 0 To UBound($copy) -1
ConsoleWrite($copy[$i] & @CRLF)
MsgBox(0, "", $copy[$i])
Next
将输出
192.168.1.2
12.15.14.45
1.1.1.1
2.2.2.2
代替
192.168.1.2
1.
12.15.14.45
14.
1.1.1.1
1.
2.2.2.2
2.
内部捕获组开始处的?:
使
它不会捕获,而只是一个小组。外层群体
捕获内部群体以及其他角色
在外部捕获组中作为单个[step | capture]。