I am trying to extract the phone number and full name from a data string, but I can’t figure out a regex pattern needed for extracting the said data, can anyone help me with it
This is the data string:
FYI, I found a regex pattern to extract email and it worked.
([a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+.[a-zA-Z0-9_-]+)
btw The tool I use to extract this data only supports positive lookahead regex patterns
Hi @Fahad_Sheji ,
Instead of regex, I would have split the entire dataset on the newline character. This would present a String array with all the characters of a line in each array items.
I would then parse through each of the array items, and try to split the items with ‘|’, since I don’t see the | being used anywere else. Once split I would check to see if my split actually worked and whether the resulting array has 3 items - i.e. Name, Email and Number.
Once this is done, I would get the 0th position as the Name and the 2nd position element as the number.
This would work depending on the size of your dataset, and whether the | symbol is present anywhere else
But for regex, I think this should suffice -
([\w|\s]+|[a-zA-Z0-9.-]+@[a-zA-Z0-9. -]+.[a-zA-Z0-9_-]+|\d*)
I’ll add the whole data string for better reference, The highlighted one is what the regex brought in.
Anyways I know it’s hard to locate it without a header, so I looked into the HTML version of the email and it had proper headers before the data such as first name, last name, phone, etc but had the HTML code between, can we easily extract from that? this is the photo