ID EN
String Functions

grepRaw

R Base 3.6.2 🇮🇩 Bahasa Indonesia

grepRaw mencari kecocokan pola substring dalam vektor mentah x.

Syntax

R
grepRaw(pattern, x, offset = 1L, ignore.case = FALSE,
        value = FALSE, fixed = FALSE, all = FALSE, invert = FALSE)

Arguments

Parameter Deskripsi
pattern raw vector containing a regular expression (or fixed pattern for fixed = TRUE) to be matched in the given raw vector. Coerced by charToRaw to a character string if possible.
x a raw vector where matches are sought, or an object which can be coerced by charToRaw to a raw vector. Long vectors are not supported.
ignore.case if FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.
offset An integer specifying the offset from which the search should start. Must be positive. The beginning of line is defined to be at that offset so "^" will match there.
value logical. Determines the return value: see ‘Value’.
fixed logical. If TRUE, pattern is a pattern to be matched as is.
all logical. If TRUE all matches are returned, otherwise just the first one.
invert logical. If TRUE return indices or values for elements that do not match. Ignored (with a warning) unless value = TRUE.

Return Value

grepRaw(value = FALSE) mengembalikan vektor bilangan bulat dari offset tempat kecocokan terjadi. Jika semua = FALSE maka panjangnya nol (tidak cocok) atau panjang satu (posisi pertama cocok). grepRaw(value = TRUE, all = FALSE) mengembalikan vektor mentah yang kosong (tidak cocok) atau bagian x yang cocok. grepRaw(value = TRUE, all = TRUE) mengembalikan daftar vektor mentah (yang berpotensi kosong) yang sesuai dengan bagian yang cocok.

Details

Tidak seperti grep, mencari pola yang cocok dalam vektor mentah x . Hal ini memiliki implikasi terutama dalam kasus all = TRUE, misalnya, pola yang cocok dengan string kosong pada dasarnya tidak terbatas dan dengan demikian dapat menyebabkan hasil yang tidak diharapkan. Argumen invert diartikan meminta mengembalikan komplemen yang cocok, yang berarti hanya untuk nilai = TRUE. Argumen offset menentukan awal pencarian, bukan pelengkap. Perhatikan bahwa invert = TRUE dengan all = TRUE akan membagi x menjadi beberapa bagian yang dibatasi oleh pola termasuk string kosong di depan dan di belakang (akibatnya penggunaan ekspresi reguler dengan "^" atau "$" dalam hal ini dapat menyebabkan hasil yang kurang intuitif). Beberapa kombinasi argumen seperti fixed = TRUE dengan value = TRUE didukung namun kurang bermakna.

Contoh

Example
R
# NOT RUN {
grepRaw("no match", "textText")  # integer(0): no match
grepRaw("adf", "adadfadfdfadadf") # 3 - the first match
grepRaw("adf", "adadfadfdfadadf", all=TRUE, fixed=TRUE)
## [1]  3  6 13 -- three matches
# }

See Also

regular expression (aka regexp) for the details of the pattern specification. grep for matching character vectors.