Regex – capture group whish is optionally enclosed in sequence of characters

Advertisements I have a file with lines I need to extract from the JSON-like syntax. My regex works good in most cases. It extracts desired symbols into a second capture group. But I noticed sometimes my desired text is optionally can be enclosed by some tags which I want to ignore. Sample file: {"title_available" "text1"}… Read More Regex – capture group whish is optionally enclosed in sequence of characters

C# Regex – How to get substring from between "_" and "\r\n"

Advertisements In example string: string input = "8240617_8240608_8240573\r\n"; i need to get only the last part: 8240573. In finale application there can be dots and letters. But it will always be end of the line and between "_" and "\r\n". I tried code below but whit no result 🙁 string input = "8240617_8240608_8240573\r\n"; string pattern… Read More C# Regex – How to get substring from between "_" and "\r\n"

How to extract multiple values matching a pattern after a specific keyword?

Advertisements Would need help on how to extract the multiple passport numbers matching after a passport keyword using a regex’s Text: my friends passport numbers are V123456, V123457 and V123458 Regex: (?<=passport)\s*(?:\w+\s){0,10}\s*(\b[a-zA-Z]{0,2}\d{6,12}[a-zA-Z]{0,2}\b) Expected matches output: V123456 V123457 V123458 Actual output: V123456 >Solution : You can’t rely on a lookbehind here since you would need a… Read More How to extract multiple values matching a pattern after a specific keyword?

Regex that matches files with two or more unique extensions

Advertisements I am trying to create regex that matches files with two or more extensions, but I want to ignore duplicate extensions. Examples of results I want: videogame.exe.exe – Don’t match unknown.pdf.exe – Match Resume.doc.docx – Match SalesNumbers.pdf.pdf – Don’t Match summary.pdf.docx – Match Currently I have the following regex: (\.\w+)(?!\1)\.\w+ This almost works. However,… Read More Regex that matches files with two or more unique extensions

Having an unknown problem with Regex processing names

Advertisements I’m parsing name strings that have strange compound formations. The current formation that’s giving me a problem is these names: Edward St. Loe Livermore Henry St. George Tucker III Henry St. John This pattern (.*)(St\.\s\w+)\s(.*) parses the first two names and completely ignores the third. This pattern (.*)(St\.\s\w+)|(St\.\s\w+\s(.*))$ returns the third name as well,… Read More Having an unknown problem with Regex processing names

REGEX Select From Where Word NOT Found Difficulty

Advertisements I need a regex to match phishing email names, where a specific name or word is NOT found. For example… John Smith (notmyemail@sodifh.com) John Smith (notmyemail@SODI.com) John Smith (jsmit34@gmail.com) John Smith (myRealEmail@mymail.com) Where the bottom email is the only legit email, and needs to be ignored. I have tried similar to: ^(J|j)ohn.(S|s)mith.*\@^((?i)\bmymail\.com\b)*$ But this… Read More REGEX Select From Where Word NOT Found Difficulty