Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
twillerror #1
Regular expression bug?
All of CF's RE functions act in a weird way, contrary to the documentation
(both CF's own, and the underlying Java Regex docs). The special characters ^
and $ are defined as: 'Boundary matchers ^ The beginning of a line $ The end
of a line' But, CF will only match the beginning or end of a STRING, not a
line within that string. Couple this with the fact that the 'Whitespace
Management' option in the administrator has no effect on the output, and there
exist only the most obscure and system dependent hacks (matching against
'['&char(10)&char(13)&']{2}') to remove the literally thousands of
empty (or whitespaced filled) lines in a typical CF generated page. Without
the abiltiy to find the true start or end of a line, its impossible to remove
them.
twillerror Guest
-
Regular Expression
Hi, I am writing a script that parses an html file (which has been retrieved as a scalar by LWP::UserAgent). The script looks for everything in... -
Regular expression help
Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract... -
Regular expression for both first and last name?
I'm new to regular expressions, can someone explain to me how I can write one that will check for 2 names, at least, for a name field? Thanks!... -
help on regular expression
Hi, I need some help on regular expression... i have following in variable $total_count $total_count = "##I USBP 000001 10:38:09(000)... -
[PHP] REGULAR EXPRESSION HELP
John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:... -
Kronin555 #2
Re: Regular expression bug?
[url]http://www.regular-expressions.info/anchors.html[/url]
[url]http://www.regular-expressions.info/java.html[/url]
From the first link:
"Using ^ and $ as Start of Line and End of Line Anchors
If you have a string consisting of multiple lines, like first line\nsecond
line (where \n indicates a line break), it is often desirable to work with
lines, rather than the entire string. Therefore, all the regex engines
discussed in this tutorial have the option to expand the meaning of both
anchors. ^ can then match at the start of the string (before the f in the above
string), as well as after each line break (between \n and s). Likewise, $ will
still match at the end of the string (after the last e), and also before every
line break (between e and \n).
In text editors like EditPad Pro or GNU Emacs, and regex tools like PowerGREP,
the caret and dollar always match at the start and end of each line. This makes
sense because those applications are designed to work with entire files, rather
than short strings.
In all programming languages and libraries discussed on this website , except
Ruby, you have to explicitly activate this extended functionality. It is
traditionally called "multi-line mode". In Perl, you do this by adding an m
after the regex code, like this: m/^regex$/m;. In .NET, the anchors match
before and after newlines when you specify RegexOptions.Multiline, such as in
Regex.Match("string", "regex", RegexOptions.Multiline)."
Kronin555 Guest
-
Adam Cameron #3
Re: Regular expression bug?
> All of CF's RE functions act in a weird way, contrary to the documentation
Which CF docs are you reading?> (both CF's own, and the underlying Java Regex docs). The special characters ^
> and $ are defined as: 'Boundary matchers ^ The beginning of a line $ The end
> of a line'
I'm reading these ones:
[url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=p art_cfm.htm[/url]
Which say:
"If the caret is at the beginning of a regular expression, the matched
string must be at the beginning of the STRING being searched."
(My emphasis).
It says STRING, not LINE.
And says same sort of thing for both ^ and $. And in both CFMX6.1 and
CFMX7.
You should read further down that page to where it discusses (?m), which is> But, CF will only match the beginning or end of a STRING, not a
> line within that string.
what you want for end-of-line, rather than end-of-string.
--
Adam
Adam Cameron Guest



Reply With Quote

