REFind()
Uses a regular expression (RE) to search a string for a pattern.
The search is case sensitive.
REFind( reg_expression=string, string=string, start=number, returnSubExpressions=boolean, scope=string, multiline=boolean );
Returns: any
Examples
writeDump(REFind("a+c+", "abcaaccdd"));
writeDump(REFind("a+c*", "Abcaaccdd"));
writeDump(REFind("['[:upper:]']", "abcaacCDD"));
writeDump(REFind("[\?&]rep = ", "report.cfm?rep = 1234&u = 5"));
<span class="nv">teststring1</span> <span class="o">=</span> <span class="s2">"The cat in the hat hat came back!"</span><span class="p">;</span>
<span class="nv">st1</span> <span class="o">=</span> <span class="nf">REFind</span><span class="p">(</span><span class="s2">"(['[:alpha:]']+)[ ]+(\1)"</span><span class="p">,</span><span class="nv">teststring1</span><span class="p">,</span><span class="m">1</span><span class="p">,</span><span class="s2">"TRUE"</span><span class="p">);</span>
<span class="nf">writeDump</span><span class="p">(</span><span class="nv">st1</span><span class="p">[</span><span class="s1">'len'</span><span class="p">][</span><span class="m">3</span><span class="p">]);</span>
<span class="nv">teststring2</span> <span class="o">=</span> <span class="s2">"AAAXAAAA"</span><span class="p">;</span>
<span class="nv">st2</span> <span class="o">=</span> <span class="nf">REFind</span><span class="p">(</span><span class="s2">"x"</span><span class="p">,</span><span class="nv">teststring2</span><span class="p">,</span><span class="m">1</span><span class="p">,</span><span class="s2">"TRUE"</span><span class="p">);</span>
<span class="nf">writeDump</span><span class="p">(</span><span class="nf">arrayLen</span><span class="p">(</span><span class="nv">st2</span><span class="p">[</span><span class="s1">'pos'</span><span class="p">]));</span>
See also
- Strings
- Regex
- string.reFind()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)