R में Intermediate Regular Expressions
Angelo Zehr
Data Journalist
| Character Class | उदाहरण |
|---|---|
\\d or [:digit:] |
0, 1, 2, 3,… |
\\w or [:word:] |
a, b, c…, 1, 2, 3…, _ |
[A-Za-z] or [:alpha:] |
A, B, C,…, a, b, c,… |
[aeiou] |
a, e, i, o या u में से कोई एक |
\\s or [:space:] |
" ", tabs या line breaks |
str_match_all() |
परिणाम |
|---|---|
"Hi John_35", "\\d" |
"3", "5" |
"Hi John_35", "\\w" |
"H", "i", "J", "o", "h", "n", "_", "3", "5" |
"Hi John_35", "[A-Za-z]" |
"H", "i", "J", "o", "h", "n" |
"Hi John_35", "[aeiou]" |
"i", "o" |
"Hi John_35", "\\s" |
" " |
| सिंटैक्स | अर्थ |
|---|---|
\\w{2} |
ठीक 2 बार |
\\w{2,3} |
न्यूनतम 2 बार, अधिकतम 3 बार |
\\w{2,} |
न्यूनतम 2 बार, कोई अधिकतम नहीं |
\\w+ |
1 या अधिक repetitions |
\\w* |
0, 1 या अधिक repetitions |
| मूल | निषेध |
|---|---|
\\d digits से match |
\\D digits को छोड़कर बाकी सब से match |
\\w word characters से match |
\\W word characters को छोड़कर बाकी सब से match |
\\s spaces से match |
\\S spaces को छोड़कर बाकी सब से match |
[a-zA-Z] alphabet से match |
[^a-zA-Z] alphabet को छोड़कर बाकी सब से match |
str_match_all("Toy Story 3", "[\\d\\s]")
परिणाम:
[,1]
[1,] " "
[2,] " "
[3,] "3"
R में Intermediate Regular Expressions