From 34ba46a5642b74db1c47bbd6be731d2c1cf7a8b8 Mon Sep 17 00:00:00 2001 From: JohnE Date: Mon, 6 Oct 2025 19:18:00 -0700 Subject: [PATCH] MOD: handles ports, multiple subdomains, and avoids invalid dots --- lib/src/utils/regex.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/src/utils/regex.dart b/lib/src/utils/regex.dart index 2873d4c..cd165d0 100644 --- a/lib/src/utils/regex.dart +++ b/lib/src/utils/regex.dart @@ -1,14 +1,10 @@ import 'package:linkfy_text/src/enum.dart'; -// String urlRegExp = - -// url regex that accept https, http, www +// url regex that accept https, http, www, subdomains, ports and paths String urlRegExp = - r'\b((https?:\/\/)?(www\.)?[a-zA-Z0-9-]{2,}\.[a-zA-Z]{2,}(?:\.[a-zA-Z]{2,})?(\/[^\s]*)?)'; - + r'\b((https?:\/\/)?(www\.)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?)'; String hashtagRegExp = r'#[a-zA-Z\u00C0-\u01B4\w_\u1EA0-\u1EF9!$%^&]{1,}(?=\s|$)'; - String userTagRegExp = r'@[a-zA-Z\u00C0-\u01B4\w_\u1EA0-\u1EF9!$%^&]{1,}(?=\s|$)'; String phoneRegExp =