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=https://www.example.com/mybook/order/newbooking/page1?id=122; sessionId=sfdsdfsd-ba57-4e21-a39f-34; Url=https://www.example.com/mybook/order/newbooking/itemList?id=76734¶=jhjdfhj&type=new&ordertype=kjkf&memberid=273647632&iSearch=true; sid=Q4hWgR1GpQb8xWTLpQB2yyyzmYRgXgFlJLGTc0QJyZbW targetUrl=https://www.example.com/ mybook/order/newbooking/page1?id=123; sessionId=0e1acab1-45b8-sdf3454fds-afc1-sdf435sdfds; Url=https://www.example.com/mybook/order/newbooking/; sid=hkm2gRSL2t5ScKSJKSJn3vg2sfdsfdsfdsfdsfdfdsfdsfdsfvJZkDD3ng0kYTjhNQw8mFZMn; targetUrl=https://www.example.com/mybook/order/newbooking/page1?id=343; Expecting the below output: Have build the below regex to capture it but its 100% accurate. It is capturing some additional part. Regex Could you
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 string. Yet, matcher.matches() returns true. Where am I going wrong?
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.168.1.253:18888 shouldn’t be matched. But when I test in regex101.com, its result is //192.168.1.254:18888/2021/03/11/896459e4-875f-455a-a2cb-768c879555e7.png. Why is that? Answer The reason the regex101.com result
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 the search string with (?i) (case insensitive
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) succeeds. In JAX-RS Spec 2.1 Final, section 3.3.2 Parameters, it states you have to
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’ or ‘E’, followed by an
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 hi
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 an assignment where i have to parse certain numbers from a