Skip to content

Tag: regex

Java regex Matcher.matches function does not match entire string

I am trying to match an entire string against a regex but the Matcher.match function returns true even when the entire string does not match. You can see from the while loop that the regex matches only parts of the string “query1” , “query2” and “query3” but not the whole s…

non-capturing group still shows?

I am trying to get the string starting from third / in a url. here is the url: http://192.168.1.253:18888/2021/03/11/896459e4-875f-455a-a2cb-768c879555e7.png I wish to get /2021/03/11/896459e4-875f-455a-a2cb-768c879555e7.png So I used the following regex (?://.+)/.+ ?: marks a non-capturing group, so //192.16…

JTable RowFilter – case insensitive

I’m having a problem with a RowFilter, I’m trying to make it display data without it being case sensitive. I tried adding “(?!)” in the RegexFilter but that only makes my table not display any data at all when I try searching. What am I doing wrong? Answer You probably wanted to prefix…

JAX-RS and RegEx @Paths with spaces

Spaces in URIs are allowed if they’re encoded, as discussed here. JAX-RS (Jersey on Payara) doesn’t seem to allow spaces defined in the path regex pattern. The above regex should match the encoded ABC%20XYZ, but it doesn’t. Request: Internally, Payara throws a 404: Removing %20 (space) succe…

Capture text between multiline text

Hello I am trying to capture a specific part of a text. I have tried different patterns but without any luck. I have tried different answers for similar questions but also without any luck. After struggling for awhile I wanted to ask it. I am not sure if it is possible at all and I am trying this in java&#823…

Why Regular Expression is not working correctly?

I was trying to solve Valid Number problem on leetcode. My choice of language for this problem is Java. Here is the problem statement if you do not wish to visit website. Problem Statement A valid number can be split up into these components (in order): A decimal number or an integer. (Optional) An ‘e&#…

Splitting string doesn’t give expected output

I want to split a given string according to the given format -> ,;:.?! .What I am doing is given below, but whenever it is encountering more than 1 space it is adding space to the array. I just want the word not the space. INPUT:: hello Hello HEllo hi hi: hi! Welcome, welcome OUTPUT:: 13 hello Hello HEllo …

How to parse certain numbers from a string using regex? [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question i had …