The three simplest regular expressions you will use in PHP | ||
| ||
| ^ indicates the string starts with the specified characters, so "^strcpy" would match any string starting with "strcpy". This would match "strcpy.com is nice" or "strcpy the pirates" but would not match "out and strcpy". $ indicates that a string finishes with the specified characters, so "strcpy$" would match any string that ended with "strcpy". This what match "What is it strcpy" or "Out and strcpy" but would not match "strcpy.com is nice" "strcpy" looks for the characters specified within the quotes, anywhere within the string. This means not only would it match "strcpy.com is nice" and "out and strcpy" it would match "Something about Mary" These can be combined and used together. Let's say that you only wanted to match the word strcpy, and not any sentances it may be contained in. You might try combining start and end searches like this: "^strcpy$" This would match only strings that both start and end with strcpy, which applies to a the word "strcpy". | ||
| | ||
| |