Flutter – Regex in TextFormField

Since WhitelistingTextInputFormatter is deprecated in Flutter as of 1.20, FilteringTextInputFormatter can be used: A TextInputFormatter that prevents the insertion of characters matching (or not matching) a particular pattern. Instances of filtered characters found in the new TextEditingValues will be replaced with the replacementString which defaults to the empty string. Since this formatter only removes characters … Read more

Apache mod_rewrite REDIRECT_STATUS condition causing directory listing

You have this condition to stop looping: ## Internal Redirect Loop Protection RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^ – [L] This works by checking internal Apache variable %{ENV:REDIRECT_STATUS}. This variable is empty at the start of rewrite module but is set to 200 when first successful internal rewrite happens. This above condition says bail out of … Read more

powershell extract text between two strings

Here is a PowerShell function which will find a string between two strings. function GetStringBetweenTwoStrings($firstString, $secondString, $importPath){ #Get content from file $file = Get-Content $importPath #Regex pattern to compare two strings $pattern = “$firstString(.*?)$secondString” #Perform the opperation $result = [regex]::Match($file,$pattern).Groups[1].Value #Return result return $result } You can then run the function like this: GetStringBetweenTwoStrings -firstString … Read more

Regular expression to match digits and basic math operators

The accepted answer can’t handle a lot of basic cases. This should do the job: ^([-+]? ?(\d+|\(\g<1>\))( ?[-+*\/] ?\g<1>)?)$ Explaination: We want to match the entire string: ^…$ Expressions can have a sign: [-+]? ? An expression consists of multiple digits or another valid expression, surrounded by brackets: (\d+|\(\g<1>\)) A valid expression can be followed … Read more