All Bundles
RegEx
Regular expression engine.
Support for following patterns:
- any ‐ .
- optional ‐ ?
- zero or more repetitions ‐ *
- one or more repetitions ‐ +
- first single match ‐ ^
- last single match ‐ $
- (one|two|three) ‐ group
- [start-end] ‐ range
Support for following special groups:
- word ‐ \w
- not word ‐ \W
- digit ‐ \d
- not digit ‐ \D
- white space ‐ \s
- not white space ‐ \S
- repeat ‐ {least, most}
Operations
Code example:
output := HttpsClient->New()->QuickGet(Web.HTTP.Url->New(url))->ToString();
output_len := output->Size();
"URL: {$input}, read: {$output_len} character(s)"->PrintLine();
"running regex..."->PrintLine();
expr := "(href|HREF|src|SRC)=(\"|')(http://|https://|/)?((\\w|\\d|-|_)+(\\.|/)?)+(\\?(\\w|\\d|-|_)+=(\\w|\\d|-|_)+)?(&(\\w|\\d|-|_)+=(\\w|\\d|-|_)+)?(\"|')";
found := Query.RegEx.RegEx->New(expr)->Find(output)<Result>;
"---"->PrintLine();
each(i : found) {
found->Get(i)->ToString()->PrintLine();
};
New
Default constructor
New(input:String)
Parameters
Name | Type | Description |
---|
input | String | regex pattern |
Find
Finds all occurrences
method : public : native : Find(input:String) ~ Vector<Result>
Parameters
Name | Type | Description |
---|
input | String | string to match against |
Return
FindFirst
Matches the first occurrence
method : public : native : FindFirst(input:String) ~ Result
Parameters
Name | Type | Description |
---|
input | String | string to match against |
Return
Type | Description |
---|
Result | matched string if found, empty string otherwise |
IsOk
Check of the regex was parsed correctly
method : public : IsOk() ~ Bool
Return
Type | Description |
---|
Bool | true if parsed, false otherwise |
Match
Matches as much of the string as possible
method : public : Match(input:String) ~ String
Parameters
Name | Type | Description |
---|
input | String | string to match against |
Return
Type | Description |
---|
String | matched string if found, empty string otherwise |
Matches as much of the string as possible
method : public : Match(input:String, offset:Int) ~ String
Parameters
Name | Type | Description |
---|
input | String | string to match against |
offset | Int | offset into the to match against |
Return
Type | Description |
---|
String | matched string if found, empty string otherwise |
MatchExact
Looks for an exact regex match
method : public : MatchExact(input:String) ~ Bool
Parameters
Name | Type | Description |
---|
input | String | string to match against |
Return
Type | Description |
---|
Bool | true if exact, false otherwise |
ReplaceAll
Replaces all occurrences of the given string
method : public : native : ReplaceAll(input:String, replace:String) ~ String
Parameters
Name | Type | Description |
---|
input | String | string to match against |
replace | String | string to replace the match with |
Return
Type | Description |
---|
String | replaced string |
ReplaceFirst
Replaces the first occurrence with the given string
method : public : native : ReplaceFirst(input:String, replace:String) ~ String
Parameters
Name | Type | Description |
---|
input | String | string to match against |
replace | String | string to replace the match with |
Return
Type | Description |
---|
String | replaced string |