Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
- Pascal
- C++
- C#
- C#
- D
- Dart
- Elixir
- Erlang
- Fortran
- Go
- Haskell
- JS
- Java
- Java
- Lua
- Lua
- PHP
- Perl
- Python
- Python
- Ruby
- Rust
- Rust
- Rust
OK := Pos(LowerCase(AWord), LowerCase(S)) > 0;
Word is a predefined type in Pascal, so I named the variable AWord.
ok = s.Contains(word, StringComparison.CurrentCultureIgnoreCase);
The existing C# implementation is overly naïve in cultures such as Turkey which use different capitalisation rules to English. This implementation respects the current culture's capitalisation rules.
In some situations it may be more appropriate to use the InvariantCultureIgnoreCase or OrdinalIgnoreCase options instead.
In some situations it may be more appropriate to use the InvariantCultureIgnoreCase or OrdinalIgnoreCase options instead.
bool ok = s.ToLower().Contains(word.ToLower());
bool ok = s.toUpperCase().contains(word.toUpperCase());
Note: this will not work for characters containg diacritics
ok = s =~ ~r/#{word}/i
Re = re:compile(Word, [caseless, unicode]),
Ok = re:run(S, Re) =/= nomatch.
function u_i(string, substr)
character (len=*), intent(in) :: string, substr
integer :: i,j, c1, c2, u_i
u_i = 0
out: do i=1,len(string)-len(substr)+1
c1 = iachar(string(i:i))
if (c1 >= iachar('a') .and. c1 <= iachar('z')) c1 = c1 - 32
do j=0,len(substr)-2
c2 = iachar(substr(j+1:j+1))
if (c2 >= iachar('a') .and. c1 <= iachar('z')) c2 = c2 - 32
if (c1 /= c2) cycle out
end do
u_i = i
return
end do out
end function u_i
ok = u_i(string, word) /= 0
var lowerS = s.toLowerCase();
var lowerWord = word.toLowerCase();
var ok = lowerS.indexOf(lowerWord) !== -1;
import static java.util.regex.Pattern.compile;
import static java.util.regex.Pattern.quote;
import java.util.regex.Pattern;
Pattern p = compile("(?i)" + quote(word));
boolean ok = p.matcher(s).find();
ok = s.toLowerCase().contains(word.toLowerCase());
local ok=string.find(string.lower(s),string.lower(word),nil,true)~=nil
Disable search pattern by setting fourth param to true.
$ok = stripos($word, $s) === false;
my $ok = $s =~ /\Q$word/i;
Unicode compliance is hard.
ok = word.lower() in s.lower()
ok = s.match?( /#{word}/i )
Regular expressions can be interpolated. The i means case-insensitive.