Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to match a line not containing a word in Java Regex
Example
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NoRegTest {
public static void main(String[] args) {
String s="^fun";
Pattern pattern = Pattern.compile(s);
Matcher matcher = pattern.matcher("Java is fun");
if(!matcher.find()) {
System.out.println("not found");
}
}
}
Output
not found
Advertisements