rule:
- Greedy pattern is to match as much as possible
- Lazy mode is as few matches as possible
Such as the string <div> a123 </ div> <div> b321 </ div>
- Using the regular expression <div>. * </ Div> matches the entire string <div> a123 </ div> <div> b321 </ div>
- If you want to match only the content of the first div tag <div> a123 </ div>, use the regular expression <div>. *? </ Div>
to sum up:
- Regular expression, which means that the string repeats a few characters? + * {} Defaults to greedy mode
- To switch to lazy mode, add one after the metacharacter?
[Java interview questions and answers] sorting recommendations
- Basics and Grammar
- set
- network programming
- Concurrent programming
- Web
- Safety
- Design Patterns
- frame
- Algorithms and data structures
- abnormal
- File parsing and generation
- Linux
- MySQL
- Oracle
- Redis
- Dubbo