Here we can question like "does the given string match with the pattern?"
Matching Characters
- '.' Matches any character except a newline
- '^' Matches the start of the string
- '$' Matches the end of the string / before the newline
- '*' eg: ha* will match ‘h’, ‘ha’, or ‘h’ followed by any number of ‘a’s.
- '+' eg: ha+ will match ‘h’ followed by any non-zero number of ‘a’s
- '?'
- *?, +?, ?? greedy match.where +,?,* looks for all possible matches of string in entire text given.
- {m} eg: a{6}will match six 'a' characters not less than it
- {m,n} eg: a{3,5} will match from 3 to 5 'a' characters.
- '\' Escapes special characters ('*', '?').
- [] Indicate a set of characters in a set:
- e.g. [amk] will match 'a',
'm', or 'k'
No comments:
Post a Comment