310 likes | 435 Views
RegExp Theory. Finite State Machines. What is a FSM?. Used in CS theory classes Learned before more complex machines like the Turing Machine We’ll use a specific machine and a standard language (grammar) Grep Patterns are a language for a common text Finite State Machine. Pattern Searching.
E N D
What is a FSM? • Used in CS theory classes • Learned before more complex machines like the Turing Machine • We’ll use a specific machine and a standard language (grammar) • Grep Patterns are a language for a common text Finite State Machine
Search 4 a String • fjdklswmcpgtwbvkgfksdsopkdmebcipwmzniugmcttcsctwbvcvoppqmzlgfdwhncishhadsjwbaozhjakwoiatqva • find “sct” in the string the above text • think about how you looked for it
Example Pattern Match C T T Input we are searching in: C C T C S C T S Searching for:
Example Pattern Match C Machine State Position in the input T T C C T C S C T S Searching for: Input we are searching in
Example Pattern Match C Machine State Position in the input T T C C T C S C T S Searching for: Input we are searching in
Example Pattern Match C T T C C T C S C T S Searching for: Input we are searching in
Example Pattern Match C T T C C T C S C T S Searching for: Input we are searching in
Example Pattern Match C T T C C T C S C T S Searching for: Input we are searching in
Example Pattern Match T C C T C S C T S Searching for: Input we are searching in
Example Pattern Match C C T C S C T S Searching for: Input we are searching in A Match was found
Vague Searches • Search multiple times • repeat the process X times • Wildcard / Variable • Find: *, Any_Shape • How do you write this down in a concise way?
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in
Example Pattern Match Searching for: ANY Input we are searching in NOPE
Example Pattern Match Searching for: ANY Input we are searching in
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in NO match
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in No MATCH
Example Pattern Match Searching for: ANY Input we are searching in
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in No MATCH
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH
Example Pattern Match Searching for: ANY Input we are searching in Shape MATCH! WE FOUND IT