Reputation:
I'm trying to remove all text between an email regex, and a specific "word/string".
Example data:
[email protected]:123rwefwrekfwsei983:93qfujri249tu-ewrgifhjn:Speaker$500$
My purpose is to remove/slice/purge everything between the EmailRegex:
and Speaker
So the desired output would be: [email protected]:Speaker$500$
The email regex will always be the same, but the string will sometimes differentiate if I have to use it for other things in the future.
The email regex I use is: [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}
I have not tried anything myself so far, as I'm inexperienced with this. Just to note there's millions of lines, and my preference is using GNU/Cygwin.
Upvotes: 0
Views: 36
Reputation: 88626
With awk. Use :
as input and output field separator and print first and last column:
awk 'BEGIN{FS=OFS=":"}{print $1,$NF}' file
Output:
[email protected]:Speaker$500$
See: 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR
Upvotes: 0