You need to take a look at zero width matching constructs:
(?=X) X, via zero-width positive lookahead
(?!X) X, via zero-width negative lookahead
(?<=X) X, via zero-width positive lookbehind
(?<!X) X, via zero-width negative lookbehind
More Related Contents:
- How to split a string if any chracter is found in java
- Split Java String by New Line
- Regex for splitting a string using space when not surrounded by single or double quotes
- Split string to equal length substrings in Java
- Why in Java 8 split sometimes removes empty strings at start of result array?
- Split string with dot as delimiter
- Splitting on comma outside quotes
- Java string split with “.” (dot) [duplicate]
- Splitting a string at every n-th character
- Split string into array of character strings
- How to split String with some separator but without removing that separator in Java? [duplicate]
- Split regex to extract Strings of contiguous characters
- Extracting pairs of words using String.split()
- Java String.split() Regex
- Split a string, at every nth position
- Java String.split() sometimes giving blank strings
- Tokenizing Error: java.util.regex.PatternSyntaxException, dangling metacharacter ‘*’
- Understanding regex in Java: split(“\t”) vs split(“\\t”) – when do they both work, and when should they be used
- How to Split a mathematical expression on operators as delimiters, while keeping them in the result?
- How exactly does String.split() method in Java work when regex is provided?
- Java split is eating my characters
- Split string into sentences
- Split string into repeated characters
- How can split a string which contains only delimiter?
- Java’s Scanner vs String.split() vs StringTokenizer; which should I use?
- Java replace all square brackets in a string
- Specific String validation using regex
- Regexp Java for password validation
- Check if string ends with certain pattern
- java.util.regex.PatternSyntaxException: Dangling meta character ‘+’ near index 0 +