I am looking for a regular expression that will test for matches against a string such as:
mxtreme1.log:May 12 07:00:00 10.1.1.175 postfix/cleanup[48145]: C2C9FFA730: fullname=, sender= LOGINNAME @company.com , from=LOGINNAME@company.com, recip=LOGINNAME@company.com, prior=, as_score=0, as_strategy=M, code=W, actions=FFFFFFFFFFFTFFFFFFFFFF, analysis=F000FFF000TTT000F000TFT000000TTSS3000059900033-F1F-FF00000000F000FFF000000000000F1FFF000F000
where the entire part in bold is a match, but LOGINNAME can be any number of random characters.
Any help would be greatly appreciated, Thank you,
That would be something like:
sender=[^@]+@company\.com
(You were explicitly stating that only the LOGINNAME part would be variable.)
To test all of the above solutions, i personally love using 'The Regex Coach'
Just google for that string and its a freeware that has served me well.
PS: I dont own nor have any sort of vested interest in the product or the team that built it.
我很确定在电子邮件地址中逗号不是有效的,因此只要后面总是逗号,您应该可以通过以下方式获得它:
/(sender=[^,]+?),/
You can try this:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$
But look at this post to get why RegEx and emails address are problematic.
Also this to add the SENDER=:
^[\w]+=[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.