tag:blogger.com,1999:blog-19967453.post9016407547919335624..comments2023-09-28T04:33:10.550-07:00Comments on Musings of a Software Developer: Phone Interview Question ...Krishna Bhargava Vangapanduhttp://www.blogger.com/profile/16813193547125152985noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-19967453.post-80116775901338327402008-10-09T11:02:00.000-07:002008-10-09T11:02:00.000-07:00That is what I said, I am not a RegEx expert and h...That is what I said, I am not a RegEx expert and have never invested more than a minute learning RegEx. Somehow I feel I could do things using string manipulations but agreed RegEx is good. Anyway different code down here.<BR/><BR/>public static void RunSnippet()<BR/> {<BR/> string code = "foo (bar ( new Point(x, graph.getY()) ));";<BR/> code = Replace(code,'(');<BR/> code = Replace(code,')');<BR/> Console.WriteLine(code);<BR/> }<BR/> public static string Replace(string code,char ch)<BR/> {<BR/> string[] splits = code.Split(ch);<BR/> string fCode=string.Empty;<BR/> foreach(string split in splits)<BR/> fCode+=string.Format("{0} {1} ",split,ch);<BR/> fCode = fCode.Substring(0,fCode.Length-3);<BR/> return fCode.Trim();<BR/> }<BR/><BR/>Took me 3 minutes to be exact to come up with better code. So 6 minutes ... <BR/><BR/>Anyway I appreciate your comments. It made me think I can write better code. And yet i do not want to learn RegEX :DKrishna Bhargava Vangapanduhttps://www.blogger.com/profile/16813193547125152985noreply@blogger.comtag:blogger.com,1999:blog-19967453.post-64652351972072435652008-04-01T21:19:00.000-07:002008-04-01T21:19:00.000-07:00thats lousy code (when i stack it up against some ...thats lousy code (when i stack it up against some of the stuff i saw on your site seemed interesting ... ).<BR/><BR/><BR/><A HREF="http://www.regular-expressions.info/examples.html" REL="nofollow"> Reg Ex guide for slackers.</A><BR/><BR/>:)<BR/><BR/>Btw, decent blog.<BR/><BR/>RickAnirudh Vyashttps://www.blogger.com/profile/15366409490581047766noreply@blogger.com