hyTags
HomeHome DocumentationDocumentation

string-match

Finds all matches of a substring or pattern in a string. Either substring or pattern must be provided, but not both.
Parameter
Type
Description
self
String
String to search
substring
String?
Substring to match
pattern
String?
Regular expression pattern to match
return
[string]
Array of all matched substrings
Test Case:Match pattern finds all occurrences
    <div></div>
    
    <string-new value="a1b2c3">
    <string-match pattern="[0-9]">
    <array-get-size>
    <assert-equal value="3" type="number">
    
    👆 Try to change something!
  • Test Case:Match substring finds all occurrences
      <div></div>
      
      <string-new value="hello hello hello">
      <string-match substring="hello">
      <array-get-size>
      <assert-equal value="3" type="number">
      
      👆 Try to change something!
    • Test Case:No matches returns empty array
        <div></div>
        
        <string-new value="hello">
        <string-match pattern="[0-9]">
        <array-is-empty>
        <assert-true>
        
        👆 Try to change something!
      • Test succeeded Test failed