함수 preg_split_delim_capture()

1 개요[ | ]

함수 preg_split_delim_capture()

2 같이 보기[ | ]

3 C++[ | ]

C++
Copy
#include <iostream>
#include <vector>
#include <regex>
using namespace std;

int main() {
    string s("aaa1bbb2ccc");
    regex r("([0-9])");
    vector<std::string> tokens(sregex_token_iterator(s.begin(), s.end(), r, {-1, 0}), sregex_token_iterator());
    for (string t: tokens) cout << t << ", "; // aaa, 1, bbb, 2, ccc, 
}
Loading

4 JavaScript[ | ]

JavaScript
Copy
console.log( 'aaa1bbb2ccc'.split(/([0-9])/) );
["aaa", "1", "bbb", "2", "ccc"] 

5 PHP[ | ]

PHP
Copy
$keywords = preg_split('/([0-9])/', 'aaa1bbb2ccc', -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($keywords);
Loading