I am creating a user input form where a user can enter his name and I want to use a regex for the following pattern: ^[A-Za-z_äÄöÖüÜß_.-]* It only should accept the above letters, and dots if any and slashes if any. Moreover I want it to accept white spaces but not at the beginning and not at the end and…
Tag: regex
Regex to capture the staring with specific word or character and ending with either one of the word
Want to capture the string after the last slash and before either a (; sid=) word or a (?) character. sample data: sessionId=30a793b1-ed7e-464a-a630; Url=https://www.example.com/mybook/order/newbooking/itemSummary; sid=KJ4dgQGdhg7dDn1h0TLsqhsdfhsfhjhsdjfhjshdjfhjsfddscg139bjXZQdkbHpzf9l6wy1GdK5XZp; targetUrl=…
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̷…
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 …