FAQ Database Discussion Community


Java regex expression trouble in split function call

java,regex,string,split,regex-greedy
I am having some trouble with creating a regular expression in java, where I want it to match all parts of a string that have a single ; and none are a ;; in the string. Such as in the string today;i;;drank water the ; after today would be a...

Regex for URL to sites

regex,sitemap,regex-negation,regex-greedy,regedit
I have two URLs with the patterns: 1.http://localhost:9001/f/ 2.http://localhost:9001/flight/ I have a site filter which redirects to the respective sites if the regex matches. I tried the following regex patterns for the 2 URLs above: http?://localhost[^/]/f[^flight]/.* http?://localhost[^/]/flight/.* Both URLS are getting redirected to the first site, as both URLs are...

C++ Regex: non-greedy match

c++,regex,c++11,c++14,regex-greedy
I'm currently trying to make a regex which matches URL parameters and extracts them. For example, if I got the following parameters string ?param1=someValue&param2=someOtherValue, std::regex_match should extract the following contents: param1 some_content param2 some_other_content After trying different regex patterns, I finally built one corresponding to what I want: std::regex("(?:[\\?&]([^=&]+)=([^=&]+))*"). If...

Java regular expression matching two consecutive consonants

java,regex,string,regex-greedy
I'm trying to match only strings with two consecutive consonants. but no matter what input I give to myString this never evaluates to true, so I have to assume something is wrong with the syntax of my regex. Any ideas? if (Pattern.matches("([^aeiou]&&[^AEIOU]){2}", myString)) {...} Additional info: myString is a substring...

Regex to get lbs and ozs i.e. 16lb 4ozs and it's variations

regex,regex-greedy
I am trying to get a regex pattern to match the following for lbs and ozs, I am 50% of the way there having used : https://regex101.com/ to get this far: 6lb14ozs 6 lb 14ozs 6 lb 14ozs 6 lb 14 ozs 6 lbs 14ozs 6 lb 14ozs 69 lb...

How can I create a regex to match the inner-most match or work from right-to-left?

regex,regex-negation,regex-lookarounds,regex-greedy,grunt-usemin
I'm trying to match the strings for image references but am picking up a little too much when there's an expression involved. In this example http://www.regexr.com/3b3ub, you'll see I'm doing good on the 1st and 3rd matches but I'm getting too much in the 2nd match. I only want the...

Regex to avoid data duplication in delimited string?

regex,regex-lookarounds,regex-greedy
I am trying to validate the data which will be string value with the , delimited. What I want is to validate that there should not be repetition of the same value within the sting. Ex. my value would be. data1 = "value1,value2,value3,va-lu4,value 6,value1";//should fail data2 = "value1,value2,value3,va-lu4,value 6";//should pass...