Skip to main content

Posts

Showing posts from November, 2013

Basics of Regular expressions

Basic Syntax of Regular Expressions (as from PHPBuilder.com ) First of all, let's take a look at two special symbols: '^' and '$'. What they do is indicate the start and the end of a string, respectively, like this: "^The": matches any string that starts with "The"; "of despair$": matches a string that ends in the substring "of despair"; "^abc$": a string that starts and ends with "abc" -- that could only be "abc" itself! "notice": a string that has the text "notice" in it. You can see that if you don't use either of the two characters we mentioned, as in the last example, you're saying that the pattern may occur anywhere inside the string -- you're not "hooking" it to any of the edges. There are also the symbols '*', '+', and '?', which denote the number of times a character or a sequence of characters may occur. What they mean