Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.
-
Jerry Baker #1
DW RegExp broken, or me?
If I have the following string:
theText = "http://www.google.com/image.gif"
and I apply this regular expression to it in DW:
theText = theText.replace(/\.(.*)$/, "$1");
I get the whole string. It seems to me that it should only return "gif".
The parenthesis is between an end-of-line anchor and an escaped dot.
That should mean that $1 is only the text between the end of the line
and the last dot.
Am I getting too sleepy?
--
Jerry Baker
Automatic ALT text on all images
HTML and XHTML doctype switching with a mouse click
"Insert Image+" and "Insert (X)HTML Doctypes" Extensions
[url]http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn103&authorid=21726084[/url]
Jerry Baker Guest
-
regexp help
sjaak wrote at Thu, 26 Jun 2003 12:35:08 +0200: Simple way: s/(\.html?">)(</a>)/$1route$2/g; If you do a lot of such stuff, a HTML parser... -
regexp help please!
I'm writing a PHP script inspired by smartypants and textile (but for PHP), which among other things does smart quoting. However, I want to avoid... -
i need a regexp
Hello, That's easy: $s = array ( "<br />\n\r<br />", "<br />\n<br />", "<br />\r<br />", "<br />\n\n\n\n\n\n<br />" ); foreach($s as $i) { -
regexp
Anton Arhipov wrote: You mean If you find any upper case word within quotes remove quotes right ? $str = 'abc "BLAH" aaa "eef" '; print... -
regexp help...
Hi all, I have a string that for all practical purposes should probably be a list (array). I need one line from the string and need to send the... -
Joe Makowiec #2
Re: DW RegExp broken, or me?
On 18 Nov 2005 in macromedia.exchange.extensions.dreamweaver, Jerry
Baker wrote:
I just ran it through the regex tester in XNews> If I have the following string:
>
> theText = "http://www.google.com/image.gif"
>
> and I apply this regular expression to it in DW:
>
> theText = theText.replace(/\.(.*)$/, "$1");
>
> I get the whole string. It seems to me that it should only return
> "gif". The parenthesis is between an end-of-line anchor and an
> escaped dot. That should mean that $1 is only the text between the
> end of the line and the last dot.
>
> Am I getting too sleepy?
([url]http://xnews.newsguy.com[/url]). You've got 3 dots (periods, 0x2e) in
theText, and your expression matches the first dot, so the expression
returns "google.com/image.gif" Try looking for the first dot after the
slash: /\/.*\.(.*)$/
--
Joe Makowiec
[url]http://makowiec.net/[/url]
Email: [url]http://makowiec.net/email.php[/url]
Joe Makowiec Guest
-
Jerry Baker #3
Re: DW RegExp broken, or me?
Joe Makowiec wrote:
Then DW gives me "http:gif"> I just ran it through the regex tester in XNews
> ([url]http://xnews.newsguy.com[/url]). You've got 3 dots (periods, 0x2e) in
> theText, and your expression matches the first dot, so the expression
> returns "google.com/image.gif" Try looking for the first dot after the
> slash: /\/.*\.(.*)$/
--
Jerry Baker
Automatic ALT text on all images
HTML and XHTML doctype switching with a mouse click
"Insert Image+" and "Insert (X)HTML Doctypes" Extensions
[url]http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn103&authorid=21726084[/url]
Jerry Baker Guest
-
Joe Makowiec #4
Re: DW RegExp broken, or me?
On 18 Nov 2005 in macromedia.exchange.extensions.dreamweaver, Jerry
Baker wrote:
Well, think this through. What precedes any of what you actually want?> Joe Makowiec wrote:>>> I just ran it through the regex tester in XNews
>> ([url]http://xnews.newsguy.com[/url]). You've got 3 dots (periods, 0x2e) in
>> theText, and your expression matches the first dot, so the
>> expression returns "google.com/image.gif" Try looking for the
>> first dot after the slash: /\/.*\.(.*)$/
> Then DW gives me "http:gif"
If they all have [url]http://,[/url] then include that in the regex:
http:\/\/
If they aren't all preceded by [url]http://,[/url] then it would be (http:\/\/)?
(the ? means "0 or one of what's in the preceding ()"); note that this
would change your reference from $1 to $2.
Then you can have anything, up to the next slash:
..*\/
Then anything:
..*
Then the dot preceding the extension:
\.
then the extension at the end of the line:
(.*)$
and the whole regex is:
/http:\/\/.*\/.*\.(.*)$/
--
Joe Makowiec
[url]http://makowiec.net/[/url]
Email: [url]http://makowiec.net/email.php[/url]
Joe Makowiec Guest
-
Jerry Baker #5
Re: DW RegExp broken, or me?
Joe Makowiec wrote:
Thanks for the assistance. The regex that finally worked is:> and the whole regex is:
>
> /http:\/\/.*\/.*\.(.*)$/
..match(/\.[^\/]*$/)
--
Jerry Baker
Automatic ALT text on all images
HTML and XHTML doctype switching with a mouse click
"Insert Image+" and "Insert (X)HTML Doctypes" Extensions
[url]http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn103&authorid=21726084[/url]
Jerry Baker Guest



Reply With Quote

