ALL
How regular expression works
Rob Pike wrote 30 lines of codes to realize a simple regular expression matcher in his book The practice of Programming. This piece of code is really cool. Let's take a look at the code.Meaning of different characters.CharacterMeaningcGeneral character.Match any single character^Match start of a string$Match end of a string*Match zero or many occurrences of a character/*match :Test the regexp in text*/int match(char* regexp,char* text){ if(regexp[0] == '^') return matchhere(regexp+1,text); do{ /*Check the strin...
3,383 0 C REGULAR EXPRESSION IMPLEMENTATION ROB PIKE