正则理解
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m18s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m18s
This commit is contained in:
parent
1afc5ac178
commit
b3e27eda1b
@ -341,7 +341,7 @@
|
|||||||
"__id__": 108
|
"__id__": 108
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 116
|
"__id__": 116
|
||||||
@ -3412,7 +3412,7 @@
|
|||||||
"__id__": 187
|
"__id__": 187
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 209
|
"__id__": 209
|
||||||
@ -5293,7 +5293,7 @@
|
|||||||
"__id__": 119
|
"__id__": 119
|
||||||
},
|
},
|
||||||
"_children": [],
|
"_children": [],
|
||||||
"_active": false,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 215
|
"__id__": 215
|
||||||
@ -5310,7 +5310,7 @@
|
|||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": -233.353,
|
"x": -220,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -171,9 +171,43 @@ export function wrapRichTextBySpace(richText: RichText, key: string, dict, lang)
|
|||||||
|
|
||||||
// key like this: Label_Rules_6_14_2 <img src='dates' /> Label_Rules_6_14_3
|
// key like this: Label_Rules_6_14_2 <img src='dates' /> Label_Rules_6_14_3
|
||||||
const segmentArr: Segment[] = [];
|
const segmentArr: Segment[] = [];
|
||||||
const regex = /Label_[^<\s]+|<img[^>]+>/g;
|
|
||||||
|
//Label_[^<\s] 表示由Label开头,遇到<或空白(\s)则停止
|
||||||
|
//+表示前面的字符类可能出现多次
|
||||||
|
//|表示另一种组合,匹配其中任意一种
|
||||||
|
//<img[^>]+>表示由img开头,遇到>则停止,并在结尾再添加一个>
|
||||||
|
const regexp = /Label_[^<\s]+|<img[^>]+>/g;
|
||||||
|
|
||||||
|
|
||||||
|
// console.log('返回所有匹配的字符串', key.match(regexp))
|
||||||
|
// let matchArr = key.match(regexp)
|
||||||
|
// matchArr.forEach(match => {
|
||||||
|
// if (match.startsWith("Label_")) {
|
||||||
|
// let key = match.split("Label_")[1]
|
||||||
|
// if (dict[key]) {
|
||||||
|
// segmentArr.push({ type: "label", value: dict[key] });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// segmentArr.push({ type: "image", value: match }); // "<img src='dates' />"
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// console.log('返回所有匹配的字符串', key.matchAll(regexp))
|
||||||
|
// let matchArr = [...key.matchAll(regexp)]
|
||||||
|
// matchArr.forEach(match => {
|
||||||
|
// if (match[0].startsWith("Label_")) {
|
||||||
|
// let key = match[0].split("Label_")[1]
|
||||||
|
// if (dict[key]) {
|
||||||
|
// segmentArr.push({ type: "label", value: dict[key] });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// segmentArr.push({ type: "image", value: match[0] }); // "<img src='dates' />"
|
||||||
|
// }
|
||||||
|
// });
|
||||||
let match: RegExpExecArray | null;
|
let match: RegExpExecArray | null;
|
||||||
while ((match = regex.exec(key)) !== null) {
|
while ((match = regexp.exec(key)) !== null) {
|
||||||
if (match[0].startsWith("Label_")) {
|
if (match[0].startsWith("Label_")) {
|
||||||
|
|
||||||
let key = match[0].split("Label_")[1]
|
let key = match[0].split("Label_")[1]
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
{
|
{
|
||||||
/* Base configuration. Do not edit this field. */
|
/* Base configuration. Do not edit this field. */
|
||||||
"extends": "./temp/tsconfig.cocos.json",
|
"extends": "./temp/tsconfig.cocos.json",
|
||||||
|
|
||||||
/* Add your custom configuration here. */
|
/* Add your custom configuration here. */
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": false
|
"strict": false,
|
||||||
|
"lib": [
|
||||||
|
"ES2020",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable",
|
||||||
|
"ScriptHost"
|
||||||
|
],
|
||||||
|
"target": "ES2020"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user