human
Compare two strings considering only alphanumeric characters | Function to check alphanumeric equality of both strings.
variable declaration.
Length of first string.
Length of second string.
To check each and every character of both string.
If the current character of the first string is not an alphanumeric character , increase the pointer i.
If the current character of the second string is not an alphanumeric character , increase the pointer j.
if all alphanumeric characters of both strings are same , then return true.
if any alphanumeric characters of both strings are not same , then return false.
If current character matched , increase both pointers to check the next character.
If not same , then return false.
Function to print Equal or Unequal if strings are same or not.
check alphanumeric equality of both strings.
if both are alphanumeric equal , print Equal.
otherwise print Unequal.
Driver code"
Solution in Python:
 ... Give me a code to compare two strings considering only alphanumeric characters and the other steps required?
assistant
#Here is code to compare two strings considering only alphanumeric characters and the other steps required.
 def CompareAlphanumeric ( str1 , str2 ) :
	i = 0
	j = 0
	len1 = len ( str1 )
	len2 = len ( str2 )
	while ( i <= len1 and j <= len2 ) :
		while ( i < len1 and ( ( ( str1 [ i ] >= ' a ' and str1 [ i ] <= ' z ' ) or ( str1 [ i ] >= ' A ' and str1 [ i ] <= ' Z ' ) or ( str1 [ i ] >= '0' and str1 [ i ] <= '9' ) ) == False ) ) :
			i += 1
		while ( j < len2 and ( ( ( str2 [ j ] >= ' a ' and str2 [ j ] <= ' z ' ) or ( str2 [ j ] >= ' A ' and str2 [ j ] <= ' Z ' ) or ( str2 [ j ] >= '0' and str2 [ j ] <= '9' ) ) == False ) ) :
			j += 1
		if ( i == len1 and j == len2 ) :
			return True
		elif ( str1 [ i ] != str2 [ j ] ) :
			return False
		else :
			i += 1
			j += 1
	return False
def CompareAlphanumericUtil ( str1 , str2 ) :
	res = CompareAlphanumeric ( str1 , str2 )
	if ( res == True ) :
		print ( " Equal " )
	else :
		print ( " Unequal " )
if __name__ == ' _ _ main _ _ ' :
	str1 = " Ram , ▁ Shyam "
	str2 = " ▁ Ram ▁ - ▁ Shyam . "
	CompareAlphanumericUtil ( str1 , str2 )
	str1 = " abc123"
	str2 = "123abc "
	CompareAlphanumericUtil ( str1 , str2 )