Skip to main content
Solved

Extract username from Email using Regex in ontology mapping

  • August 12, 2024
  • 7 replies
  • 43 views

vanitharaj1208
Forum|alt.badge.img+14

extract Example@ from Example@domain.com

Best answer by f3rz

@vanitharaj1208 both regex patterns works for me:

1. with @ 

Result during ingestion (before regex):

 

2. without @ 

 

 

To view values after mapping process I clicked on "Show results" under 3-dot menu:

 

 

 

 

7 replies

f3rz
Staff
Forum|alt.badge.img+10
  • Staff
  • August 13, 2024

vanitharaj1208
Forum|alt.badge.img+14

i tried its not working thats why i asked the question


f3rz
Staff
Forum|alt.badge.img+10
  • Staff
  • Answer
  • August 13, 2024

@vanitharaj1208 both regex patterns works for me:

1. with @ 

Result during ingestion (before regex):

 

2. without @ 

 

 

To view values after mapping process I clicked on "Show results" under 3-dot menu:

 

 

 

 


ScottieJ
Staff
Forum|alt.badge.img+4
  • Staff
  • August 13, 2024

According to our documentation , regular expressions supports look ahead and look behind, but does not support groupings. The former method should be sufficient for isolating a username from an email address. Could there have been a difference if versions of SecOps between these examples and if so maybe there has been a change in regex. instead of "\\w" try a greedy wild card ".*" to see if it could be the special character "\\w (word character)"  not working correctly


vanitharaj1208
Forum|alt.badge.img+14

its not working

 


f3rz
Staff
Forum|alt.badge.img+10
  • Staff
  • August 14, 2024

its not working

 


I think it is working, to validate the result you need to click 3-dot icon as shown on a screenshot:

 

When you howerover your mouse above "green" mapped value, it shows only original value, but not end result of mapping.


ScottieJ
Staff
Forum|alt.badge.img+4
  • Staff
  • August 14, 2024

I think it is working, to validate the result you need to click 3-dot icon as shown on a screenshot:

 

When you howerover your mouse above "green" mapped value, it shows only original value, but not end result of mapping.


Agreed, I tested here as well and the look ahead works, but note that if the user has a " . " in the name like Joe.smith@acme.com, then you will only get "smith" if your regex is "  \\w+?(?=@)  ", you may be better off using the wild card in the regex like "  \\w+.*(?=@) ". 

When I checked the result in the vertical dot menu, my result was as expected