skip to Main Content

Special Regular Expression match in javascript

I need JavaScript special regex pattern to convert the input string to required string. Input String: google.com/q=abc?param1=[foo,bar]&optional=true&param2=[bar,baz] Output String: google.com/q=abc?param1=foo&optional=true&param2=bar This is my code. function transformUrl(inputUrl) { var pattern = /[([^,]]+),([^,]]+)]/g; var outputUrl = inputUrl.replace(pattern, function (match, group1) { return…

VIEW QUESTION

Php – Regex to get decimal zeros

My regex doesn't work as expected when I run my code, but when I test it on a website the regex does exactly as expected. See my function: function checkDecimais($numero){ if($numero > 0){ preg_match('/^([0]+).([0]*)([1-9])/', $numero, $matches); if(isset($matches[2])){ return strlen($matches[2]); }else{…

VIEW QUESTION
Back To Top
Search