J
Jari Williamsson
What't the most elegant way to find a substring match at the very start
of a string?
Currently I'm using this approach:
a = "long string"
key = "long"
if a[0, key.length] == key then
...while this might look ok, it doesn't look so good with constant strings:
if a[0, 4] == "long" then
or
if a[0, "long".length] == "long" then
I guess what I'm looking for is something like:
if a.startswith("long") then
Is there any such solution?
Best regards,
Jari Williamsson
of a string?
Currently I'm using this approach:
a = "long string"
key = "long"
if a[0, key.length] == key then
...while this might look ok, it doesn't look so good with constant strings:
if a[0, 4] == "long" then
or
if a[0, "long".length] == "long" then
I guess what I'm looking for is something like:
if a.startswith("long") then
Is there any such solution?
Best regards,
Jari Williamsson