.startswith code example

Example 1: js startswith

var str = "Hello world, welcome to the universe.";
var n = str.startsWith("Hello");

Example 2: python startswith

text = "Python is easy to learn."

result = text.startswith('is easy')
# returns False
print(result)

result = text.startswith('Python is ')
# returns True
print(result)

result = text.startswith('Python is easy to learn.')
# returns True
print(result)

Example 3: python startswith

# str -> the prefix you are looking for 
# beg -> where to start looking for the prefix
# end -> where to stop looking for the prefix

str.startswith(str, beg=0,end=len(string))

Example 4: javascript multiple startswith

//There is NO possibility to passing an Array
//like startsWith(["Mon" | "Tues"])
if (newStr4.startsWith("Mon") || newStr4.startsWith("Tues") || ...)

//although you can use regular expression,
//but performance are lower than the solution above
 if (newStr4.matches("(Mon|Tues|Wed|Thurs|Fri).*"))

Example 5: python startswith

str.startswith(prefix[, start[, end]])

Tags:

Php Example