Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

How to create a case insensitive Regexp from a non-case insensitive Regexp?

To add the case-insensitive "ignore case" option on the fly:

original = /abc/
insensitive =
                original.options |

To make the match case-insensitive without using the "ignore case" option, a possible solution is to create a regexp that matches uppercase letters and lowercase letter like this:

original = /abc/ 
insensitive = /[Aa][Bb][Cc]/

If your original regexps are all letters as in your examples, you can automate like this:

original = /abc/
insensitive =
"[#{$&.upcase}#$&]" })

If your original regexps are more than just letters, then you'll need a more sophisticated automation. For example, if your original regexps make use of braces, character classes, named captures, etc. then you'll need code that take these into account. (Thanks to hobbs in the comments for emphasizing this)

Categories : Ruby

Related to : How to create a case insensitive Regexp from a non-case insensitive Regexp?
Case-insensitive "contains" in Linq
the easy way is to use ToLower() method var lists = rec.Where(p => p.Name.ToLower().Contains(records.Name.ToLower())).ToList(); a better solution (based on this post: Case insensitive 'Contains(string)') var lists = rec.Where(p => CultureInfo.CurrentCulture.CompareInfo.IndexOf (p.Name, records.Name, CompareOptions.IgnoreCase) >= 0).ToList();

Categories : C#
'which' command in R with case insensitive
You can index it with grepl by using the argument x <- c("col7", "COL73", "Col17", "CoL73", "cOl73") grepl("col73", x, # [1] FALSE TRUE FALSE TRUE TRUE Similarly, grep returns the numeric index grep("col73", x, # [1] 2 4 5 For data frame column subsets df[grepl("col73", names(df),]

Categories : R
How to use indexOf() case insensitive
You can Use Overloaded Method IndexOf("punctuation", StringComparison.OrdinalIgnoreCase); Eg. List<string> fnColArr = new List<string>() { "Punctuation", "period", "Space", "and", "yes" }; foreach (string item in fnColArr) { if (item.IndexOf("puNctuation", StringComparison.OrdinalIgnoreCase) >= 0) { Co

Categories : C#
Case-insensitive primary key of type nvarchar where ß != ss
The closest I can get to a workaround is using an indexed view to add a unique constraint on UPPER(ID) to stop primary key violation that is not picked up by the binary collation used on the actual primary key, e.g. CREATE TABLE CollationTest ( ID NVARCHAR(50) COLLATE Latin1_General_BIN NOT NULL, CONSTRAINT PK_CollationTest_ID PRIMARY KEY (ID) ); GO CREATE VIEW dbo.CollationTestConst

Categories : SQL
Case Insensitive String Array Comparison
Your code wont compile as you are not overriding the Object's equals method which has signature like public boolean equals(Object obj) Also to do comparison, you could do the following in your modified equals as below: if (array == foo.array) { return true; } if (array == null || foo.array == null) { return false; } int length = array.length; if (foo.length != length) return f

Categories : Java
Recently Add
Making invalid method names valid
how to split the string in a file in ruby
ruby - pipe-in from one class to another
Ruby: Using instance variables from other classes
Exclude beginning string from regex
RegEx code works in theory but not when code is run
ruby bitwise product
How to sanitalize string with nested html tags but keep tag?
Ruby trying to dynamically create unicode string throws "invalid Unicode escape" error
Best way to implement process output in ruby
Ruby. How to know which class instance method is defined?
Checking equality between variable and object
ruby self in an instance methods in a module
Problems with rspec scope in before blocks
Querying a specific cell with known column and row
Parsing through nested hash using .present? - undefined method `[]' for nil:NilClass (NoMethodError)
"params" doesn't work in Ruby (Sinatra framework)
Specifying a Puppet + Ruby version matrix in CircleCI
How to upload a file using RestClient in Ruby?
Shibboleth authentication in Rails
Random, intermittent "argument out of range" error while parsing CSV and parsing time
Ruby: Wrong number of Arguments for a subclass changes number of arguments
amalgamate two ruby arrays
Geocoder request.location returns nil
Access most recent table row and its data
how to search multiple word in the same file using ruby and the get the output which contains those words
MongoDB search query for stats
rake command parsing options after --
Ruby: cannot load such file - LoadError
Understanding attributes in AWS DynamoDB with Ruby
© Copyright 2017 Publishing Limited. All rights reserved.