Tags "regex" Result

case-insensitive regular expressions

What's the best way to use regular expressions with options (flags) in Haskell I use Text.Regex.PCRE The documentation lists a few interesting options like compCaseless, compUTF8, ... But I don't know how to use them with (=~) Solution All the Text.Regex.* modules make heavy use of typeclasses, which are there for extensibility and "overloadi

it1352 0 2019-05-19

Inlining CSS in C#

I need to inline css from a stylesheet in c#. Like how this works. http://www.mailchimp.com/labs/inlinecss.php The css is simple, just classes, no fancy selectors. I was contemplating using a regex (?<rule>(?<selector>[^{}] ){(?<style>[^{}] )}) to strip the rules from the css, and then attempting to do simple string replaces

it1352 2 2019-05-14

Inlining CSS in C#

I need to inline css from a stylesheet in c#. Like how this works. http://www.mailchimp.com/labs/inlinecss.php The css is simple, just classes, no fancy selectors. I was contemplating using a regex (?<rule>(?<selector>[^{}] ){(?<style>[^{}] )}) to strip the rules from the css, and then attempting to do simple string replaces

it1352 2 2019-05-10

Template literal inside of the RegEx

I tried to place a template literal inside of a RegEx, and it didn't work. I then made a variable regex which holds my RegEx, but it still not giving me the desired result. However if I console.log(regex) individually, I do receive the desired RegEx, such as /. ?(?=location)/i, /. ?(?=date)/i and so on, but once I place regex inside the .replace i

it1352 2 2019-05-22

Regular expression to select all whitespace that isn't in quotes?

I'm not very good at RegEx, can someone give me a regex (to use in Java) that will select all whitespace that isn't between two quotes? I am trying to remove all such whitespace from a string, so any solution to do so will work. For example: (this is a test "sentence for the regex") should become (thisisatest"sentence for the regex")

it1352 4 2019-05-22

From wildcards to regular expressions

I want to allow the two main wildcards ? and * to filter my data. Here is how I'm doing now (as I saw on many websites): public boolean contains(String data, String filter) { if(data == null || data.isEmpty()) { return false; } String regex = filter.replace(".", "[.]") .replace("?", ".")

it1352 3 2019-05-17

Haskell: 'No instance for' arising from a trivial usage of Regex library

Following the (accepted) answer from this question, I am expecting the following to work: Prelude Text.Regex.Posix Text.Regex.Base.RegexLike Text.Regex.Posix.String> makeRegex ".*" (makeRegex is a shortcut for makeRegexOpts with predefined options) However, it doesn't: <interactive>:1:0: No instance for (RegexMaker regex compOpt e

it1352 4 2019-05-19

How to check if a string contains only digits in Java

In Java for String class there is a method called matches, how to use this method to check if my string is having only digits using regular expression. I tried with below examples, but both of them returned me false as result. String regex = "[0-9]"; String data = "23343453"; System.out.println(data.matches(regex)); String regex = "^[0-9]"; St

it1352 3 2019-05-21

Sanitization of User-Supplied Regular Expressions in PHP

I want to create a website where users can test regular expressions (there are many out there already...such as this one: http://www.pagecolumn.com/tool/pregtest.htm). Basically, the user provides a regular expression and some sample text, and the results of the regex evaluation will be spit back. I want to evaluate the regex on the server side wi

it1352 0 2020-07-03