```
def is_palindrome(s)
i, j = 0, s.length - 1
while i < j
i += 1 while !(s[i] =~ /[A-Za-z0-9]/) && i < s.length - 1
j -= 1 while !(s[j] =~ /[A-Za-z0-9]/) && j > 0
return true if i == s.length - 1 && j == 0
return false if s[i].downcase != s[j].downcase
i += 1
j -= 1
end
true
end
```