Regular Expressions

  1. What is the secret behind ^ and $ which makes understanding expressions easier?
    • ^ represents "starts with" so it's ALWAYs First
    • ^Dal   Never d^al or dal^

    • $ represents "ends with" so it's Always last
    • Dal# never #Dal or D#al

    So if you search ^Dal# the result can only be Dal since it starts with and ends with "Dal"
  2. '*', '+', and '?', What do these symbols mean?
    "zero or more", "one or more", and "zero or one."
  3. What is the difference between ^ and [^] as in ^me or [^me]
    ^me means that it must start with "me" but [^me] means that it can't contain "me"
  4. What do regular expresssions need to be enclosed by, including variables
    "/ /"
  5. What PHP function checks for matches?
    preg_match()
  6. Added to look for something at the end of a string
    $ as in bob$ matches dumbbob but not bobdumb
  7. Added to look for something at the start of a string
    ^ as in ^cat matches catalog but not concatenate
  8. Wildcard
    . period
  9. Wildcard for zero or more
    *
  10. Look for either a A or B make sure you have the symbol for or
    (A|B)
  11. Requires that there be one or more of the characters it follows
    + as in (a|B) must have an a or B
  12. Search for something in a range
    [a-z]
  13. Set the range of a number of occurences. As in give me 2-5 A's
    • {2,5} as in A{2,5} is looking for
    • AA
    • AAA
    • AAAA
    • AAAAA
  14. Exclude characters....
    [^] as in [^A] means no A can be in the search
  15. When you use exclusion brackets what is special about them?
    • Everything except - ][ and ^ are taken literally. thus
    • you get a mishmash, since you can't use separaters
    • a-zA-Z0-9
  16. Wildcard for 0 or 1
    ?
  17. Escape character so you can use a . or a ^ or a $
    \
Author
dalbabes
ID
107003
Card Set
Regular Expressions
Description
Regular expression help
Updated