- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Regular expression matches multiple lines in Java
Pattern.MULTILINE will help on matching multiple lines in java. below is an example to show this −
import java.util.regex.Matcher; import java.util.regex.Pattern; public class MultiRegex { public static void main(String[] args) { if (args.length<1) { System.err.println("run the program from command line"); System.exit(1); } String regexString = args[0]; String spamString = "welcome to java world"; Pattern aPattern = Pattern.compile(regexString,Pattern.MULTILINE); Matcher aMatcher = aPattern.matcher(spamString); if (aMatcher.find()) { System.out.println("got a match"); } else { System.out.println("no match"); } } }
- Related Articles
- How to write JavaScript Regular Expression for multiple matches?
- Matching multiple lines in Java regular expressions
- Replacing all String which Matches with Regular Expression in Golang
- How can I find all matches to a regular expression in Python?
- Regular Expression "(re)" Sub-Expression in Java
- Regular Expression "[^...]" construct in Java
- Regular Expression Metacharacter in Java
- Regular Expression Metacharacter in Java
- How to write a Python regular expression that matches floating point numbers?
- Regular Expression E Metacharacter in Java.
- Regular Expression Q Metacharacter in Java
- Regular Expression "^" (caret) Metacharacter in Java
- Regular Expression "$" (dollar) Metacharacter in Java
- Regular Expression "." (dot) Metacharacter in Java
- Regular Expression "re*" Metacharacter in Java

Advertisements