[{"data":1,"prerenderedAt":344},["ShallowReactive",2],{"project-20645319":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":9,"maker":10,"posted_at":11,"year":12,"points":13,"comments":14,"rank_in_year":15,"shown_in_year":16,"top":17,"tier":18,"category":19,"subcategory":20,"format":21,"keywords":22,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":17,"aspects":33,"strip":37,"post_text":39,"what":40,"said":73,"maker_in_thread":174,"shape":181,"grid":186,"attempts":306,"same_week":307,"maker_shows":334,"maker_hidden":335,"reader_version":336,"card":337},"20645319","Python re(gex)?","A book on Python regular expressions","title","Show HN: I wrote a book on Python regular expressions",null,"asicsp",1565277275,2019,193,50,197,2195,9,"notable","learning_science","programming book","other",[23,24,25,26],"python regex","regular expressions","python re module","regex tutorial","mixed",0.318,{"positive":30,"neutral":31,"mixed":32,"critical":31},5,2,0,{"idea":34,"docs":35},{"positive":32,"critical":31},{"positive":36,"critical":32},3,[32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,36,32,36,32,32,32,30,32,32,30,30,30,38,32,32,32,38,32,32],1,"My book titled \"Python re(gex)?\" is free to download through this weekend [1][2]\n\nThe book covers both 're' and 'regex' modules, has plenty of examples and chapters also have cheatsheets and exercises.\n\nCode snippets, exercises, sample chapters, etc are available on GitHub repo [3]\n\nI used pandoc+xelatex [4] to generate the pdf.\n\n[1] https:\u002F\u002Fgumroad.com\u002Fl\u002Fpy_regex\n\n[2] https:\u002F\u002Fleanpub.com\u002Fpy_regex\n\n[3] https:\u002F\u002Fgithub.com\u002Flearnbyexample\u002Fpy_regular_expressions\n\n[4] https:\u002F\u002Flearnbyexample.github.io\u002Ftutorial\u002Febook-generation\u002Fcustomizing-pandoc\u002F",{"problem":41,"audience":50,"pricing":56,"motivation":9,"time_to_build":9,"stack":60,"openness":70,"stage":71,"team_size":72},{"value":42,"source":43,"evidence":44},"Learning Python regular expressions, including the re and regex modules","maker",[45,47],{"id":46},"post",{"id":48,"by":10,"text":49},"20645909","There are enough differences in terms of syntax and features across languages that I felt separate books would help the user better than a common one. If you consider Python's…",{"value":51,"source":52,"evidence":53},"Python programmers learning regular expressions","inferred",[54,55],{"id":46},{"id":48,"by":10,"text":49},{"value":57,"source":43,"evidence":58},"Free to download through the weekend",[59],{"id":46},[61,66],{"value":62,"source":43,"evidence":63},"Python",[64,65],{"id":46},{"id":48,"by":10,"text":49},{"value":67,"source":43,"evidence":68},"pandoc and xelatex used to generate the PDF",[69],{"id":46},"free","launched","solo",{"praise":74,"objections":102,"requests":133,"questions":134,"alternatives":153},[75,91],{"value":76,"source":77,"evidence":78},"Helpful resource and well done on the book","commenter",[79,83,87],{"id":80,"by":81,"text":82},"20646276","nathanbarry","Congrats on writing and publishing this book!",{"id":84,"by":85,"text":86},"20646169","dhairya","This is a great resource. Thank you for taking the time to write this and making it available to us!",{"id":88,"by":89,"text":90},"20653180","spazzy81","This is super helpful! I've always felt Python regex was one of the more complicated parts of the language.",{"value":92,"source":77,"evidence":93},"Interesting alternative regex syntax via rxe library",[94,98],{"id":95,"by":96,"text":97},"20646681","PieUser","This is excellent, I prefer this.",{"id":99,"by":100,"text":101},"20646174","Maro","You might like: https:\u002F\u002Fgithub.com\u002Fmtrencseni\u002Frxe So you can write: ``` username = rxe.one_or_more(rxe.set([rxe.alphanumeric(), '.', '%', '+', '-'])) domain =…",[103,114,122],{"value":104,"source":77,"evidence":105},"Regex is hard to read and often overused; parsers are better",[106,110],{"id":107,"by":108,"text":109},"20647656","AlexanderDhoore","There two kinds of text search\u002Fparse problems: - The really easy ones. A simple string search\u002Fsplit will do and a regex would be overkill. - The really hard ones. You'll need to…",{"id":111,"by":112,"text":113},"20649999","IceDane","I couldn't agree more. I honestly find it rather baffling that someone would write a book on not just regular expressions in general, but one particular variant in one particular…",{"value":115,"source":77,"evidence":116},"Dedicated Python regex book seems unnecessary since regex is language agnostic",[117,118],{"id":111,"by":112,"text":113},{"id":119,"by":120,"text":121},"20647023","just_myles","None that I know of. My thought process has always been that regex was language agnostic. I think Perl has its own version that is widely used. But other than that, I do not know.",{"value":123,"source":77,"evidence":124},"Rxe style is too verbose",[125,129],{"id":126,"by":127,"text":128},"20646565","gnulinux","Too verbose, I prefer good old regular expression.",{"id":130,"by":131,"text":132},"20646967","qwsxyh","10 lines to replace maybe 20 characters. How horribly verbose.",[],[135,142],{"value":136,"source":77,"evidence":137},"Why Python regex differs from other languages",[138],{"id":139,"by":140,"text":141},"20647988","Lordarminius","> My thought process has always been that regex was language agnostic. +1 I was surprised to find that regex in python was not much different from the language I use ruby. Would…",{"value":143,"source":77,"evidence":144},"Whether Python's re supports variable-length lookbehind",[145,149],{"id":146,"by":147,"text":148},"20645826","danso","Thanks for sharing! I only skimmed it but I liked how you include usage of the external regex module, which I hadn't realized allowed for the use of variable-length look-behinds.",{"id":150,"by":151,"text":152},"20646404","ErikCorry","The engine has support but the language doesn't expose it?",[154,158,164],{"value":155,"source":77,"evidence":156},"rxe library",[157],{"id":99,"by":100,"text":101},{"value":159,"source":43,"evidence":160},"CommonRegex module",[161],{"id":162,"by":10,"text":163},"20651143","I actually find these too verbose. May be because I didn't know about them when I started out, was using regex in cli tools and Perl scripts. There's also a module [1] which…",{"value":165,"source":77,"evidence":166},"Parser combinators and PEG grammars",[167,170],{"id":168,"by":112,"text":169},"20649945","Parser combinators are the way to go. I don't use python often enough to know if such a library exists for python, but I would assume so.",{"id":171,"by":172,"text":173},"20692800","cben","No experience with them in python, but look also for PEG grammars. They are significantly simpler than the traditional tower of lexer + ambiguous limited lookahead grammar. Plus…",{"comments":36,"answered":38,"key":175},[176,177,178],{"id":162,"text":163},{"id":48,"text":49},{"id":179,"text":180},"20651105","I don't have experience with parsers, so I cannot comment how easy\u002Fdifficult it is compared to regex. Regex can indeed lead to issues [1] but so could any other piece of code.…",{"commenters":182,"max_depth":183,"maker_replies":36,"first_comment_mins":184,"lifespan_hours":185},39,6,57,134,[187,189,193,194,197,198,199,202,205,208,210,213,216,218,221,223,226,229,231,234,236,239,241,243,246,248,251,255,257,261,262,265,266,269,272,274,275,277,278,281,285,286,289,292,295,297,298,299,302,305],[99,32,32,188,100,32],"other\u002Fneutral\u002Fnone",[190,32,32,191,192,32],"20646416","commenter\u002Fneutral\u002Fnone","foo_in_bar",[126,32,32,191,127,32],[195,32,32,191,196,32],"20647157","felixr",[95,32,32,191,96,32],[130,32,32,191,131,32],[200,32,32,191,201,32],"20647146","tW4r",[203,32,32,191,204,32],"20647413","mikorym",[206,32,32,191,207,32],"20649057","ken",[209,32,32,191,120,32],"20647052",[211,32,32,191,212,32],"20647560","wwwhizz",[214,32,32,191,215,32],"20647621","_eht",[217,32,32,191,120,32],"20647994",[219,32,32,191,220,32],"20650851","nerdponx",[222,32,32,191,120,32],"20655704",[224,32,32,191,225,32],"20647165","sweeneyrod",[227,32,32,191,228,32],"20648019","jazzyjackson",[230,32,32,191,127,32],"20648101",[232,32,32,191,233,32],"20648901","CaptainMarvel",[235,32,32,191,228,32],"20650817",[237,32,32,191,238,32],"20654016","baudehlo",[240,32,32,191,100,32],"20648789",[242,32,32,191,220,32],"20650452",[244,32,32,191,245,32],"20647329","ape4",[162,32,32,247,10,38],"maker\u002Fneutral\u002Fnone",[249,32,32,191,250,32],"20651534","killaken2000",[252,38,36,253,254,32],"20645820","project\u002Fneutral\u002Fidea","natpalmer1776",[48,38,32,256,10,38],"maker\u002Fneutral\u002Fidea",[258,38,36,259,260,32],"20645925","project\u002Fneutral\u002Fnone","nurettin",[119,38,32,191,120,32],[263,38,32,188,264,32],"20647185","caymanjim",[139,38,32,188,140,32],[267,38,32,188,268,32],"20650463","cutler",[270,38,32,188,271,32],"20650667","redis_mlc",[146,31,30,273,147,32],"project\u002Fpositive\u002Fdocs",[150,31,32,191,151,32],[276,31,32,191,147,32],"20646531",[88,36,30,273,89,32],[80,279,30,280,81,32],4,"maker\u002Fpositive\u002Fnone",[282,30,30,283,284,32],"20648002","maker\u002Fpositive\u002Fdocs","smitshah0014",[84,183,30,280,85,32],[107,287,38,288,108,32],7,"project\u002Fcritical\u002Fidea",[290,287,32,191,291,32],"20647755","gravitas",[293,287,32,188,294,32],"20647797","madelyn",[168,287,32,296,112,32],"other\u002Fneutral\u002Fidea",[171,287,32,296,172,32],[111,287,38,288,112,32],[300,287,32,191,301,32],"20652837","quickthrower2",[303,287,32,191,304,32],"20650556","castis",[179,287,32,191,10,38],[],[308,313,318,321,325,330],{"id":309,"name":310,"points":311,"category":312},"20688044","Divjoy",511,"dev_tools",{"id":314,"name":315,"points":316,"category":317},"20687398","Yack",246,"productivity",{"id":319,"name":320,"points":13,"category":312},"20698966","StoryTime",{"id":322,"name":323,"points":324,"category":312},"20653942","Tailwind.run",181,{"id":326,"name":327,"points":328,"category":329},"20653278","haskell-poker",157,"games",{"id":331,"name":332,"points":333,"category":317},"20670039","Personal Management System",153,10,false,"v2",{"id":338,"name":5,"line":6,"ai":335,"cat":19,"year":12,"points":13,"comments":14,"rec":27,"s":339,"top":17,"kw":340,"maker":10,"domain":341,"tier":18,"attempts":32,"strip":342,"url":-1,"mix":343,"praise":76,"objection":104,"sub":20},20645319,0.32,[23,24,25,26],"","0000000000000000000003030005005551000100",[30,31,32,31],1794036579711]