Argument | Description |
pat1 | String. The starting regular expression search pattern. |
pat2 | String. The ending regular expression search pattern. |
data | String. The string in which to perform the search. |
start | Long. The position within the data in which to start the search. Use 1 to start at the beginning. |
flags | Integer. Flags that control how the search is performed. Add individual flag values together. Add 1 to cause the search to match case. Add 2 to cause the search to ignore cr/lf's within the data. |
. | Matches any character. |
\< | This matches the start of a word, where a word is defined in the traditional sense, that is, letters, or number. Spaces, punctuation, CR/LF, etc. would not be included as part of a word, and thus create a break. |
\> | This matches the end of a word. See also word definition above. |
\x | This allows you to use a character x that would otherwise have a special meaning. For example, \[ would be interpreted as [ and not as the start of a character set. |
[...] | This indicates a set of characters, for example, [abc] means any of the characters a, b or c. You can also use ranges, for example [a-z] for any lower case character. |
[^...] | The complement of the characters in the set. For example, [^A-Za-z] means any character except an alphabetic character. |
^ | This matches the start of a line (unless used inside a set, see above). |
$ | This matches the end of a line. |
* | This matches 0 or more times. For example, Sa*m matches Sm, Sam, Saam, Saaam and so on. |
+ | This matches 1 or more times. For example, Sa+m matches Sam, Saam, Saaam and so on. |
NOTE: If a string contains any quote characters (") then the string must be delimited with the single quote charcter ('). For example... 'he said, "no"'
This function will also not perform a regular expression search that spans multiple lines. If the data to search contains carraige returns or line feeds, the entire matching search data for the regular expression must exist within a single line. If your regular expression must span across a line, then add 2 to the flags to have CR's and LF's temporarily converted. CR will be converted to ASCII 128 and LF will be converted to ASCII 129. If you convert CF/LF then you can include them in your search with PowerHome escape characters ~128 and ~129 respectively.
Within each search pattern you may perform multiple searches by separating your search pattern using the PowerHome escape character ~255. This is most useful when CF/LF IS NOT replaced and trying to match a particular piece of data that spans multiple lines. If you do multiple searches, the last search is used as the starting position and ending position of the returned text.
This function is often used with other PH string functions to trim a larger string, or to locate a string position within another string. See also pos(), posw(), ph_pos(), left(), mid(), right().
See also the .FAQs-String Tips-Hints Help file.
ROMId,Name, Value,Avg, "3F000001CD92C728","Refrig",39.20,37.46, "3F6000017C8BD128","Outside",23.90,19.81, "3F000001CDB2BA27","House",70.65,70.13, "3F000001CD9E6D28","Freezer",1.96,1.11, |
ph_regexdiff ('2C728', '\<', '[LOCAL1]', 1,0 ) --> finds "," (Between ..C728 and Refrig..) ph_regexdiff ('2C728', '\>', '[LOCAL1]', 1,0 ) --> finds ","Refrig ph_regexdiff ('BA27...', "7", '[LOCAL1]', 1,0 ) --> finds House", ph_regexdiff ('Refrig', "$", '[LOCAL1]', 1,0 ) --> finds ",39.20,37.46, ph_regexdiff ("3F[0-9]+","R", "[LOCAL1]", 1,0 ) --> finds CD92C728"," |