Search:
Calendar:
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |
Subscribe:
Enter your email address to subscribe to this blog.
Archives By Subject:
Action Script (2) [RSS]
Adobe (33) [RSS]
AIR (7) [RSS]
Ajax (3) [RSS]
Buzzword (1) [RSS]
CFUG (42) [RSS]
ColdFusion (70) [RSS]
Flash (6) [RSS]
Flex (40) [RSS]
Frameworks (3) [RSS]
Free Software (2) [RSS]
FXUG (22) [RSS]
General (35) [RSS]
JpgMetadataReader (3) [RSS]
jQuery (1) [RSS]
Mac (2) [RSS]
Off Topic (13) [RSS]
OpenSource (14) [RSS]
PaperVision (10) [RSS]
Spry (2) [RSS]
Transfer (1) [RSS]
Adobe (33) [RSS]
AIR (7) [RSS]
Ajax (3) [RSS]
Buzzword (1) [RSS]
CFUG (42) [RSS]
ColdFusion (70) [RSS]
Flash (6) [RSS]
Flex (40) [RSS]
Frameworks (3) [RSS]
Free Software (2) [RSS]
FXUG (22) [RSS]
General (35) [RSS]
JpgMetadataReader (3) [RSS]
jQuery (1) [RSS]
Mac (2) [RSS]
Off Topic (13) [RSS]
OpenSource (14) [RSS]
PaperVision (10) [RSS]
Spry (2) [RSS]
Transfer (1) [RSS]
Tags:
action script
adobe
air
ajax
cfug
coldfusion
flash
flex
frameworks
free software
fxug
general
jpgmetadatareader
mac
off topic
opensource
papervision
spry
Recent Entries:
Top Posts:
- [23063] Paper Vision 3D Sphere - Carousels on Steroids!
- [15577] Simple Dynamic Cursor Example in Flex2: With source code
- [14385] Simple PaperVision3D Blurring example : source code
- [13774] Simple PaperVision3D Blurring example
- [13036] Saving images from Flex using ColdFusion: Simple Example with source code
- [12609] PaperVision3D/Flex2 Carousel v0.2
- [12515] Carousel v0.2 - source code
- [11647] PaperVision Carousel0.3 - one step closer to the master plan!
- [11327] Simple Effects on a Form - Flex Example
- [10406] PaperVision3D is good for cubes! - a "geek" gift
Recent Comments:
- Simple Effects on a Form - Flex Example
Flex Newbie said: Wow! This page is by far the best page I've seen all month. It's so cool!!! It really made my day. ... [More] - Paper Vision 3D Sphere - Carousels on Steroids!
Reflexion Graphic said: Nice job ! [More] - Getting Red from my color
David said: @Promethe: Thanks for the comment. Jason uses that way too in his example. working with number as n... [More] - Getting Red from my color
Promethe said: guys... seriously: var myColor : uint = 0xef556ef; var myRed : uint = (myColor >> 16) & ... [More] - Getting Red from my color
David said: @Jason: Thanks for the example! I never like working with numbers-to-strings-to-numbers. I'll pull y... [More]
Top Commenters:
- [8] Campbell
- [8] Ben Nadel
- [6] Steve Bryant
- [6] Mark Flewellen
- [4] barry.b
- [4] Raymond Camden
- [3] John Whish
- [3] Peter Bell
- [2] riabook
- [2] carlos
My Links:
RSS:
To all you REGEX gurus out there
I have a block of text I am working with. Here is an example of it:
the start of the text here
<a href="Some text here" target="_blank" >Some text here</a>
some more text here
<a href="http://someurl">here is some stuff</a>
and some more text
<a href="Some text here" target="_blank" >Some text here</a>
some more text here
<a href="http://someurl">here is some stuff</a>
and some more text
I want to run a regex to get the "Some test here" from between the "a" tags.
When I use the regex "(<a>)(.*)(</a>)" in to The Regex Coach it happily finds the "Some text Here" a tags.
When I run this code:
<cfsavecontent variable="thisText">
the start of the text here
<a href="Some text here" target="_blank" >Some text here</a>
some more text here
<a href="http://someurl">here is some stuff</a>
and some more text
</cfsavecontent>
<cfset aBlock = reFindNoCase("(<a href=")(.*)(" target="_blank" >)(.*)(</a>)",thisText,1,1)>
<cfset aPortion = mid(thisText, aBlock.pos[3], aBlock.len[3])>
<cfdump var="#aPortion#">
the start of the text here
<a href="Some text here" target="_blank" >Some text here</a>
some more text here
<a href="http://someurl">here is some stuff</a>
and some more text
</cfsavecontent>
<cfset aBlock = reFindNoCase("(<a href=")(.*)(" target="_blank" >)(.*)(</a>)",thisText,1,1)>
<cfset aPortion = mid(thisText, aBlock.pos[3], aBlock.len[3])>
<cfdump var="#aPortion#">
I am getting from the "Some text here..." to the end a tag that is at the end of "...here is some stuff"
Can any of you regex Gurus spot my (obvious to you) mistake?
Update:
Been meaning to do this for a while... as per the comments from Steve the correct answer is:(<a href=")(.*?)(" target="_blank" >)(.*?)(</a>)
note the "?". [Steve Quote]The "?" qualifies the statement as non-greedy[/Steve Quote]
Thank you Steve!

The "?" qualifies the statement as non-greedy, which is what you want.
I won't pretend I understand what you just said, but it works.
Regex is still an unknown to me!
so the "?" says, "find the first </a> one, then stop"?
That's right.
The concept of "greedy" indicates whether the expression will find as much text as it can or as little. A greedy expression will find the largest match that it can, a non-greedy match will find the smallest.
So, the "?" makes the expression non-greedy so it will find the smallest match (in your case, just one link).
So would that suggest The Regex Coach got it wrong?
Thanks again for your help Steve!