- When expression pattern find
first match from input text,
for example now it will find the first line of the letter
M and picks up the rest of the letters.
Code:
Example input text
Mary this
Mary that
lamb died
mary cry
- Then search again a position in the input text where the match starts
StrContains
- + Counts how long matching string is
strlen
- In next loop cycle, it skip the first piece of input text.
Code:
Example input text
Mary this
Mary that
lamb died
mary cry
- And continue same way, find a match.
Code:
Example input text
Mary this
Mary that
lamb died
mary cry
- Skip first part.
Code:
Example input text
Mary this
Mary that
lamb died
mary cry
- Then will end because it not find anymore matching part inside input text.
So result was
If we use capturing parentheses in regex pattern
(x
), we get more substrings.
PHP Code:
new String:regex_expression_pattern[] = { "(\\w+) (\\w+)" }; // Same as = /(\w+) (\w+)/
Regex store matching string parts in array.
For quick example now it will pick two words what have space between of them.
Code:
Example input text
Mary this
Mary that
lamb died
mary cry
Result will be this
Code:
Example input
Example
input
Mary this
Mary
this
Mary that
Mary
that
lamb died
lamb
died
mary cry
mary
cry