Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > regular expression help finding href within window.open()

Reply
Thread Tools

regular expression help finding href within window.open()

 
 
jd
Guest
Posts: n/a
 
      04-10-2007
hi all,

i'm using regular expression to find the url of the page to be opened
using the window.open().

typical urls look like this http://domain.com/path-to-page.html

right now i'm trying href.match(/http:\/\/domain\.com\/\w?\.html/)

and this will get me http://domain.com/path but not everything to
html.

does anyone have some tips they can offer?

i've tried
href.match(/http:\/\/domain\.com\/\w*\.html/)
href.match(/http:\/\/domain\.com\/*\.html/)

and they don't work.

thanks for any help you can offer

 
Reply With Quote
 
 
 
 
Cah Sableng
Guest
Posts: n/a
 
      04-11-2007
On Apr 11, 6:31 am, "jd" <(E-Mail Removed)> wrote:
> hi all,
>
> i'm using regular expression to find the url of the page to be opened
> using the window.open().
>
> typical urls look like thishttp://domain.com/path-to-page.html
>
> right now i'm trying href.match(/http:\/\/domain\.com\/\w?\.html/)
>


'-' character is not word characters, so it \w won't make it.
Use '-' with \w enclosed by square bracket, and prepend '-' with '\'
because it is regex's special character.

try:
/^http:\/\/domain\.com\/[\w\-]+\.html/

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      04-11-2007
On Apr 11, 11:35 am, "Cah Sableng" <(E-Mail Removed)> wrote:
> On Apr 11, 6:31 am, "jd" <(E-Mail Removed)> wrote:
>
> > hi all,

>
> > i'm using regular expression to find the url of the page to be opened
> > using the window.open().

>
> > typical urls look like thishttp://domain.com/path-to-page.html

>
> > right now i'm trying href.match(/http:\/\/domain\.com\/\w?\.html/)

>
> '-' character is not word characters, so it \w won't make it.
> Use '-' with \w enclosed by square bracket, and prepend '-' with '\'
> because it is regex's special character.
>
> try:
> /^http:\/\/domain\.com\/[\w\-]+\.html/


Presumably the domain name is in a string of other stuff and will be
enclosed in quotes, so maybe:

/http:[^\'\"]+\.html/

will suit better.


--
Rob

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help with regular expression finding multiple floats Jeremy Python 6 10-26-2009 08:47 PM
Regular Expression help - href replacement Saya Perl Misc 1 01-16-2004 03:55 PM
Regular Expression replace location.href bus105 Javascript 2 12-02-2003 09:58 PM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM
Regular expression, getting href which is followed by img tag with specific src fatted Perl Misc 4 08-21-2003 08:32 AM



Advertisments