diff --git a/frappe/core/doctype/user/test_user.py b/frappe/core/doctype/user/test_user.py
index a5b54e7b8d..857e537997 100644
--- a/frappe/core/doctype/user/test_user.py
+++ b/frappe/core/doctype/user/test_user.py
@@ -266,3 +266,10 @@ class TestUser(unittest.TestCase):
self.assertEqual(extract_mentions(user_name)[0], "test-user")
user_name = "Testing comment, @test.user@example.com please check."
self.assertEqual(extract_mentions(user_name)[0], "test.user@example.com")
+ user_name = "
@test_user@example.com and @test.again@example1.com
This is a test.
"
+ self.assertEqual(extract_mentions(user_name)[0], "test_user@example.com")
+ self.assertEqual(extract_mentions(user_name)[1], "test.again@example1.com")
+ user_name = "@user@example.com Test @test-comment@xyz.com
Test for comment mentions @test@abc.com
"
+ self.assertEqual(extract_mentions(user_name)[0], "user@example.com")
+ self.assertEqual(extract_mentions(user_name)[1], "test-comment@xyz.com")
+ self.assertEqual(extract_mentions(user_name)[2], "test@abc.com")
\ No newline at end of file
diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py
index c4378dbb8c..68e178c42f 100644
--- a/frappe/core/doctype/user/user.py
+++ b/frappe/core/doctype/user/user.py
@@ -901,7 +901,7 @@ def notify_admin_access_to_system_manager(login_manager=None):
def extract_mentions(txt):
"""Find all instances of @name in the string.
The mentions will be separated by non-word characters or may appear at the start of the string"""
- txt = txt.replace("
", "
")
+ txt = txt.replace("", "
")
txt = re.sub(r'(<[a-zA-Z\/][^>]*>)', '', txt)
return re.findall(r'(?:[^\w\.\-\@]|^)@([\w\.\-\@]*)', txt)