user_property/
user_property.rs1use onig::*;
2use std::str;
3
4fn main() {
5 define_user_property(
6 "HandakuonHiragana",
7 &[
8 (0x3071, 0x3071), (0x3074, 0x3074), (0x3077, 0x3077), (0x307a, 0x307a), (0x307d, 0x307d), ],
14 );
15
16 let hay = [
18 0xe3, 0x81, 0xb1, 0xe3, 0x81, 0xb4, 0xe3, 0x81, 0xb7, 0xe3, 0x81, 0xba, 0xe3, 0x81, 0xbd,
19 'a' as u8,
20 ];
21 let hay = str::from_utf8(&hay).unwrap();
22 let reg = Regex::new("\\A(\\p{HandakuonHiragana}{5})\\p{^HandakuonHiragana}\\z").unwrap();
23
24 match reg.captures(hay) {
25 Some(caps) => {
26 println!("match at {}", caps.offset());
27 for (i, cap) in caps.iter_pos().enumerate() {
28 match cap {
29 Some(pos) => println!("{}: {:?}", i, pos),
30 None => println!("{}: did not capture", i),
31 }
32 }
33 }
34 None => println!("search fail"),
35 }
36}