Skip to content
🤔prompts chat🧠
🔍
question:Generate a valid Ruby code that implements the following function. Replace all whitespaces in a string with underscores.

answer:def replace_whitespace(string) return string.gsub(/s+/, '_') end

question:Write a React function to set the background color of an element to blue.

answer:const setBackgroundBlue = () => { document.getElementById("my-element").style.backgroundColor = "blue"; }

question:Create a Python program to validate an email address according to RFC5322 syntax.

answer:import re def validate(email): regex = r'^[a-z0-9]+[._]?[a-z0-9]+[@]w+[.]w{2,3}' if re.search(regex, email): return True else: return False

question:Python, define a function to extract characters after a given substring. String = "Hello-world-123" Substring = "-world

answer:def extract_string(str, substr): start_index = str.find(substr) if start_index == -1: return "" else: end_index = start_index + len(substr) return str[end_index:] x = extract_string("Hello-world-123", "-world") print(x)

Released under the Ad License.

has loaded