Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How to match standard email addresses with regex?
Post
How to match standard email addresses with regex?
I want to match standard email syntax (lowercased English, numbers and perhaps also some hyphens and underscores) with regex for a sed
operation that matches and changes a single email address inside a file.
The following code failed:
read new_email_address
sed -i 's/[a-zA-Z0-9-_]*@[a-zA-Z0-9-_]*.[a-z]*/"'"${new_email_address}"'"/g' FILE
I know its problematic in the sense that files can have two or more email addresses and a global change is dangerous, but this is primarily just for learning and practice regex and sed
.
1 comment thread