Export reused kanji regex into own file
This commit is contained in:
parent
8c7253fd93
commit
eaa5510942
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:jisho_study_tool/services/kanji_regex.dart';
|
||||
import 'package:unofficial_jisho_api/api.dart';
|
||||
|
||||
import '../../../../models/themes/theme.dart';
|
||||
|
@ -34,8 +35,8 @@ class KanjiKanaBox extends StatelessWidget {
|
|||
|
||||
bool get hasFurigana => word.reading != null;
|
||||
|
||||
String get kana => '${word.reading ?? ""}${word.word ?? ""}'
|
||||
.replaceAll(RegExp(r'\p{Script=Hani}', unicode: true), '');
|
||||
String get kana =>
|
||||
'${word.reading ?? ""}${word.word ?? ""}'.replaceAll(kanjiRegex, '');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:jisho_study_tool/services/kanji_regex.dart';
|
||||
import 'package:unofficial_jisho_api/api.dart';
|
||||
|
||||
import './parts/common_badge.dart';
|
||||
|
@ -55,7 +56,7 @@ class _SearchResultCardState extends State<SearchResultCard> {
|
|||
return jlpt.last;
|
||||
}
|
||||
|
||||
List<String> get kanji => RegExp(r'(\p{Script=Hani})', unicode: true)
|
||||
List<String> get kanji => kanjiRegex
|
||||
.allMatches(
|
||||
widget.result.japanese
|
||||
.map((w) => '${w.word ?? ""}${w.reading ?? ""}')
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
final kanjiRegex = RegExp(r'\p{Script=Hani}', unicode: true);
|
Loading…
Reference in New Issue