+ 1

I have many emails and i want to extract the emails wich username start with A or a and finish with r or R and .........

and it doesnt matter wich email i will extract....i only want to extract emails wich username start with A or a and finish with r or R Whether it's Yahoo or Facebook or any comany and whether the email end with .com or .net or .org or any thing so i wrote this code and it doesnt work....why? can any one correct it for me?? https://code.sololearn.com/ckLHS4aV32IN/?ref=app

4th Jul 2018, 6:38 PM
Omar
Omar - avatar
6 Answers
+ 7
This one should find all o...r@ patterns, but you need to delete the spaces inside the regex. The problem is, though, that consecutive emails have no precise ending, unless you are sure they are always beginning with the capital letter, so you can use it as a rule.
4th Jul 2018, 6:51 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 7
Omar o \w represents a "word" character, so any of the a-z, A-Z, 0-9 ranges or an underscore (no spaces!). There are only two strings meeting that criteria and so they are returned.
4th Jul 2018, 9:00 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 4
That's because .+ is greedy and looks for the longest expression meeting the criteria without distinguishing between actual characters. And so the longest possible is the whole string from Om |ar@ until Amer| @gmail.com
4th Jul 2018, 7:32 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
0
Kuba SiekierzyƄski ok but now i was editing the code and i could reach the emails wich i want by this code https://code.sololearn.com/cxtq7wg9BU8T/?ref=app but in this code👇i but .+ instead of \w and it doesnt works.why?? https://code.sololearn.com/cxTEjB9Wty3x/?ref=app
4th Jul 2018, 7:18 PM
Omar
Omar - avatar
0
Kuba SiekierzyƄski but why \w isnot greedy like .+ ?
4th Jul 2018, 8:17 PM
Omar
Omar - avatar
0
Kuba SiekierzyƄski thanks alotâ˜ș
4th Jul 2018, 9:21 PM
Omar
Omar - avatar