Recently, I have been experimenting with regular expression (fondly called as 'regex') with a goal of understanding it's practical application in day today work. Sharing my learning in this article to help anyone read, understand and write basic constructs of regular expressions and its applications. It can be as simple or complex as we would like! Happy Reading!!
The example I would like to share is validating names. You might think what big deal in validating names, it is just words with alphabets in it. But when I started implementing, I noticed different attritubes a name can possibly have... to name a few Title (Mr., Mrs., Ms., Dr.), First Name, Middle name, Last name, Special characters (like Hyphens, Apostrophes), Suffix (Jr, Sr, I, IV etc.,). So what we think is simple can get complex based on the perfection we might need.
I'm going to present 2 examples covering different basic patterns.