tracker issue : CF-3134978

select a category, or use search below
(searches all categories and all time range)
Title:

ColdFusion will not support look ahead or look behind regular expressions

| View in Tracker

Status/Resolution/Reason: To Fix//

Reporter/Name(from Bugbase): Andrew Scott / Andrew Scott (Andrew Scott)

Created: 03/11/2012

Components: Language

Versions: 9.0.1

Failure Type:

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Normal / Most users will encounter

Locale/System: English / Windows 7

Vote Count: 0

Problem Description:

This is a kicker for me, as I am in need of this right now, and there seems no work around.

(?<="").+(?="") is supposed to get what's between something like

src="path/images/test.jpg"

Error message is

Error Type: org.apache.oro.text.regex.MalformedPatternException : [N/A]
Error Messages: Sequence (?<...) not recognized

I would have thought that all CF would be using the underlying java reg expression from java.util.regex

Steps to Reproduce:

Actual Result:

Expected Result:

Any Workarounds:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3134978

External Customer Info:
External Company:  
External Customer Name: ascott67
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

  1. March 13, 2012 00:00:00: 1_regex.PNG

Comments:

Can you tell me the exact scenario where you are using this regular expression i.e. the function in which you are using this regular expression. Also, can you send the program in Java or any other language in which you're able to run the same example. (Comment added from ex-user id:sagarg)
Comment by Adobe D.
20135 | March 12, 2012 02:04:51 AM GMT
Sure I a, using it against a string that has the value src="/path/images/imgaename.png" BUt it wont matter because ColdFusion complains about the string <= which is look behind I believe in regex.
Comment by External U.
20136 | March 12, 2012 05:19:23 AM GMT
Sagar, I have asked for help on Google+ regarding this issue as well. It appears that there are other things that ColdFusion is not doing right here as well. I added your name to the comments, so could you read up and give these examples a go please. As you can see by all accounts there must be something else going on here as well.
Comment by External U.
20137 | March 12, 2012 01:34:26 PM GMT
I did see the comments on the Google + post and the regular expression presented was \"([^"]+)\". This example works: <cfset testString = 'blah blah src="images/test.gif" blah blah'> <cfset groups = ReFind('src=\"([^"]+)\"', testString, 1, true)> <cfset match = Mid(testString, groups.pos[2], groups.len[2])> <!--- match should contain what you want ---> <cfoutput>#match#</cfoutput> Can you let me know the regular expression and the context in which it is failing. (Comment added from ex-user id:sagarg)
Comment by Adobe D.
20138 | March 12, 2012 11:31:11 PM GMT
Ok here is the code <cfsavecontent variable="test" > that would suit them, and the change now means that you can not do this anymore. That<a href="http://www.andyscott.id.au/enclosures/NoFacebookAppDirectory_2.jpg"><img align="left" alt="NoFacebookAppDirectory" border="0" height="185" src="http://www.andyscott.id.au/enclosures/NoFacebookAppDirectory_thumb.jpg" style="background-image: none; border-right-width: 0px; margin: 9px 12px 5px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="NoFacebookAppDirectory" width="244" /></a> sort of impact on people who are using the pages option to get a presence on FaceBook, whether it be as an knew would not be interested in these things.</p> <p> Now what happens is that no matter what the application or game posts to <a href="http://www.andyscott.id.au/enclosures/fbpost-privacy-setting-aps1_2.jpg"><img align="right" alt="fbpost-privacy-setting-aps1" border="0" height="157" src="http://www.andyscott.id.au/enclosures/fbpost-privacy-setting-aps1_thumb.jpg" style="background-image: none; border-right-width: 0px; margin: 10px 0px 10px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="fbpost-privacy-setting-aps1" width="244" /></a>your wall, and it is then up to your friend whether <a href="http://www.andyscott.id.au/enclosures/images%20(1)_2.jpg"><img align="left" alt="images (1)" border="0" height="160" src="http://www.andyscott.id.au/enclosures/images%20(1)_thumb.jpg" style="background-image: none; border-right-width: 0px; margin: 10px 15px 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="images (1)" width="203" /></a>Another recent change to FaceBook is with the Chat Bar, which I will admit I didn&#39;t use that often. However when I did use this feature, I actually found it work very well in its current form. I could see all my groups and who was online in those groups, and be able to go offline to any group with the easy of a single click. Now if you from FaceBook, even though I have said <a href="http://www.andyscott.id.au/enclosures/images_2.jpg"><img align="right" alt="images" border="0" height="139" src="http://www.andyscott.id.au/enclosures/images_thumb.jpg" style="background-image: none; border-right-width: 0px; margin: 10px 0px 0px 10px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="images" width="189" /></a>above that this might happen, and I </cfsavecontent> <cfset images = reMatchNoCase("(?i)src=""[^>]*[^>](.*)(gif|jpg|png)""\1", test)> <cfdump var="#images#" /> <cfset imagePaths = arrayNew(1)> <cfloop array="#images#" index="i"> <cfset temp = reMatchNoCase('\"([^"]+)\"', i) /> <cfdump var="#temp#"> </cfloop>
Comment by External U.
20139 | March 12, 2012 11:36:04 PM GMT
See attached image for result
Comment by External U.
20140 | March 12, 2012 11:36:22 PM GMT
My understanding is that this is supposed to remove the quotes from the string, which you can clearly see is not the case.
Comment by External U.
20141 | March 12, 2012 11:38:01 PM GMT
But even that aside, the listed regex in this ticket still wont work in CF9/10 either.
Comment by External U.
20142 | March 12, 2012 11:38:37 PM GMT
<cfloop array="#images#" index="i"> <cfset temp = reMatchNoCase('src=\"([^"]+)\"', i)/> <cfset images1 = ReFind('src=\"([^"]+)\"', temp[1], 1, true)> <cfset match = Mid(temp[1], images1.pos[2], images1.len[2])> <cfdump var="#match#"> </cfloop> the above code works just fine. (Comment added from ex-user id:sagarg)
Comment by Adobe D.
20143 | March 14, 2012 12:30:17 AM GMT
Yes, but you had to add the Mid to remove the quotes. From what I understand if the reFind() uses an expression like "()" then it is what is in the parenthesis that should be extracted. At least this is what people are telling me, and what that google+ post and comments had been suggesting.
Comment by External U.
20144 | March 14, 2012 12:36:41 AM GMT
Can you pls explain how this is being fixed? Are you finally dropping Apache ORO? Blimey. Andrew, if you need to use look behinds, why don't you just use the Java regex engine? ColdFusion (via Apache ORO) *does* support look-aheads, btw. Both positive and negative. It's look-behinds CF doesn't have natively.
Comment by External U.
20145 | December 09, 2014 06:39:28 PM GMT