Quantcast
Channel: regex Archives - Java Code Geeks
Browsing all 17 articles
Browse latest View live

Split a string by regular expression

This is an example of how to split a String using regular expression. Splitting a String with a regular expression implies that you should: Compile a given String regular expression to a Pattern, using...

View Article


Get all digits from a string

With this example we are going to demonstrate how to get all digits from a String, using a regular expression. In short, to get all digits from a String you should: Use a given String with letters and...

View Article


Find occurances of a letter in a string

In this example we shall show you how to find occurances of a specific letter in a String. To find occurances of a letter in a String one should perform the following steps: Compile a given String...

View Article

Simple positive Lookbehind

This is an example of a simple positive look behind. Positive look behind methods assert the existence of a pattern to the left of the position of a String. You can form positive look behinds by...

View Article

Strip extra spaces in a string

With this example we are going to demonstrate how to strip extra spaces in a String. In short, to strip extra spaces in a String you should: Use a given String with spaces between words. Use...

View Article


Matcher.appendReplacement example – Part 2

In this example we shall show you how to use Matcher.appendReplacement(StringBuffer sb, String replacement) API method to append to a StringBuffer the result of a Matcher. To use a StringBuffer to...

View Article

Determine if a string matches a pattern exactly

This is an example of how to determine if a String matches to a Pattern exactly. Using a Matcher to check if a String matches to a specified Pattern implies that you should: Compile a given String...

View Article

Find duplication in strings example

With this example we are going to demonstrate how to find duplication in Strings. In order to check if there are duplications in a String we have created a Matcher against a specified Pattern and used...

View Article


Simple validation example

In this example we shall show you how to make a simple validation of a String, using a Matcher against a specified Pattern. To make a simple String validation one should perform the following steps:...

View Article


Spring Expression Language Example

The Spring Expression Language (SpEL for short) is a powerful expression language that supports querying and manipulating an object graph at runtime. SpEL expressions can be used with XML or annotation...

View Article

java.util.regex.PatternSyntaxException Example

In this example we will discuss about java.util.regex.PatternSyntaxException. This exception is thrown when a regex (a regular exception) pattern is not correct, i.e. has syntax errors. The...

View Article

Groovy Regex Example

In this example I will show you how to use regular expressions in Groovy. 1. Groovy and Regular Expressions Groovy is one of the most commonly used JVM languages and regular expressions (or simply...

View Article

Groovy Regex Example

1. Introduction Regular Expression is a character sequence defines search pattern especially for pattern matching with strings. You may see Regular Expression as Regex or Regexp in software world. In...

View Article


Java 9 Regular Expressions Example

1. Introduction In this example we will explore the java.util.regex package and the abstractions contained within it that facilitate the usage of regular expressions in Java 9. Even though the common...

View Article

MongoDB Regular Expressions Example

Hello readers, a regular expression or regex is a sequence of characters that explains a specific search pattern. In this tutorial, we will learn how to use the regular expressions in the Mongo...

View Article


Obtain Regex Pattern Matches Indexes

In the realm of Java programming, working with strings and patterns is indispensable for numerous applications. Regular expressions, often referred to as regex, offer a potent tool for both pattern...

View Article

Convert Unicode Encoding String to Letters

Dealing with strings encoded in Unicode is a common task in Java programming, especially in multilingual applications where text comes in various scripts and languages. Java provides mechanisms to...

View Article

Browsing all 17 articles
Browse latest View live