<commit_before>let text = '哈哈Good <pink>好</end> a你<b>好blue</end>好，再来<pink>一段</end>文字';

// let found = text.match(/\<\w+\>(.+?)\<\/end\>+/g);
// console.log(found);
// if (found && found.index >= 0) {
//   console.log('found');
// }

const re = /\<\w+\>(.+?)\<\/end\>+/g;
const myArray = text.match(re);
console.log(myArray);
console.log(re.lastIndex);

// let result;
// while ((result = re.exec(text)) != null) {
//   document.write(result);
//   document.write("<br />");
//   document.write(re.lastIndex);
// }

// myArray2 = text.match(re);
// console.log(myArray2);
// console.log(re.lastIndex);

// var regex1 = RegExp('foo*', 'g');
// var str1 = 'table football, foosball';
// var array1;
//
// while ((array1 = regex1.exec(str1)) !== null) {
//   console.log(`Found ${array1[0]}. Next starts at ${regex1.lastIndex}.`);
//   // expected output: "Found foo. Next starts at 9."
//   // expected output: "Found foo. Next starts at 19."
// }
<commit_msg>test new js regular expression<commit_after>let text = '哈哈Good <pink>好</end> a你<b>好blue</end>好，再来<pink>一段</end>文字';

// let found = text.match(/\<\w+\>(.+?)\<\/end\>+/g);
// console.log(found);
// if (found && found.index >= 0) {
//   console.log('found');
// }

const re = /\<\w+\>(.+?)\<\/end\>+/g;
const myArray = text.match(re);
console.log(myArray);
console.log(re.lastIndex);

// let result;
// while ((result = re.exec(text)) != null) {
//   document.write(result);
//   document.write("<br />");
//   document.write(re.lastIndex);
// }

// myArray2 = text.match(re);
// console.log(myArray2);
// console.log(re.lastIndex);

// var regex1 = RegExp('foo*', 'g');
// var str1 = 'table football, foosball';
// var array1;
//
// while ((array1 = regex1.exec(str1)) !== null) {
//   console.log(`Found ${array1[0]}. Next starts at ${regex1.lastIndex}.`);
//   // expected output: "Found foo. Next starts at 9."
//   // expected output: "Found foo. Next starts at 19."
// }

// ECMAScript正则表达式6个最新特性
// https://blog.fundebug.com/2018/08/30/ecmascript-regular-expression-new-features/?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=toutiao.io

const pattern1 = /(\d{4})-(\d{2})-(\d{2})/u;
const result1 = pattern1.exec('2017-01-25');
console.log(result1[0]); // 打印"2017-01-25"
console.log(result1[1]); // 打印"2017"
console.log(result1[2]); // 打印"01"
console.log(result1[3]); // 打印"25"


const pattern2 = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u;
const result2 = pattern2.exec('2017-01-25');
console.log(result2.groups.year); // 打印"2017"
console.log(result2.groups.month); // 打印"01"
console.log(result2.groups.day); // 打印"25"

for (let value of result1) {  // weex的sdk js环境不支持这个写法
  console.log(`result1_value=${value}`);
}
{'fraction_non_alphanumeric': 0.25744047619047616, 'fraction_numerical': 0.03869047619047619, 'mean_word_length': 3.4226973684210527, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 30, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1175397', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1101, 'n_words': 184}