String matching: Difference between revisions
Content added Content deleted
Line 3,603: | Line 3,603: | ||
0123 |
0123 |
||
first line is a suffix of the second line</pre> |
first line is a suffix of the second line</pre> |
||
=={{header|Vala}}== |
|||
<lang vala>void main() { |
|||
var text = "一二三四五六七八九十"; |
|||
var starts = "一二"; |
|||
var ends = "九十"; |
|||
var contains = "五六"; |
|||
var not_contain = "百"; |
|||
stdout.printf("text: %s\n\n", text); |
|||
stdout.printf("starts with %s: %s\n", starts, text.has_prefix(starts) ? "true" : "false"); |
|||
stdout.printf("ends with %s: %s\n", ends, text.has_suffix(ends) ? "true" : "false"); |
|||
stdout.printf("starts with %s: %s\n", starts, text.has_suffix(starts) ? "true" : "false"); |
|||
stdout.printf("contains %s: %s\n", contains, text.contains(contains) ? "true" : "false"); |
|||
stdout.printf("contains %s: %s\n", not_contain, text.contains(not_contain) ? "true" : "false"); |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
text: 一二三四五六七八九十 |
|||
starts with 一二: true |
|||
ends with 九十: true |
|||
starts with 一二: false |
|||
contains 五六: true |
|||
contains 百: false |
|||
</pre> |
|||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
Line 3,643: | Line 3,671: | ||
16 |
16 |
||
33 </pre> |
33 </pre> |
||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
<lang vb>Function StartsWith(s1,s2) |
<lang vb>Function StartsWith(s1,s2) |