473,940 Members | 8,900 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

regular expression help finding href within window.open()

jd
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

Apr 10 '07 #1
2 2339
On Apr 11, 6:31 am, "jd" <john.dava...@g mail.comwrote:
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/

Apr 11 '07 #2
On Apr 11, 11:35 am, "Cah Sableng" <cahsabl...@gma il.comwrote:
On Apr 11, 6:31 am, "jd" <john.dava...@g mail.comwrote:
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

Apr 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2630
by: Keith Morris | last post by:
Hi all! I'm creating a mini CMS that will store content in a MySQL database. What I am trying to do is parse the content and replace certain keywords with a link. The keywords and associated links are kept in a MySQL table. Here is an example. $keyword = "Widgets Technology Co."; $location = "http://www.widgets.com/about";
9
10370
by: Ron Adam | last post by:
Is it possible to match a string to regular expression pattern instead of the other way around? For example, instead of finding a match within a string, I want to find out, (pass or fail), if a string is a partial match to an re. Given an re of 'abcd and a bunch of other stuff' This is what i'm looking for:
1
6701
by: SROSeaner | last post by:
I am working on an ASP page which looks in a set of text for web page URLs. Using the VBScript.RegExp regular expression object, I have this regular expression: +\.+\.+/ And it works well finding URL's such as: windowsupdate.microsoft.com, www.cnn.com, etc.
5
2547
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL, and then reconstruct another URL based on it. For example, I need to scan a web page looking for something like <a href="some_dir/list_20050815100225.csv">. I don't know in advance what the date/time in the file name will be. I need to take the...
4
2273
by: gene.ellis | last post by:
Hello everyone, This should be extremely simple for youregular expression gurus out there. I am looking for a regular expression that will look for the hyperlinks within a string, and then add some simple code before the hyperlinks, but only if they do not match a certain URL. For example. $string ="This is a <a href='http://www.ur1.com'>Hyperlink</a> and this is a <a href='http://www.ur2.com'> Hyperlink</a>";
1
2314
by: passion_to_be_free | last post by:
I am writing a javascript that will make an http request, sort through the html for any links on the page, and then store them for future processing. To test things, I pasted html source code into my text editor, ran a GREP search using the following regular expression: (<a *href\s*=\s*")(+)("*>) And the appropriate links were highlighted correctly. I then
25
5206
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How do I gain access to the expression (not the matches) at runtime? Thanks, Mike
2
2024
by: comp.lang.php | last post by:
I am trying to replace within the HTML string $html the following: With Where I'm replacing "action=move_image" with "action=<?= $_REQUEST ?>"
0
1967
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use of string manipulation where they seek through the string back and forth doing replacements to substitute in the needed HTML code. I am convinced that this can be done with a few regular expressions. Unfortunately my knowledge of regular...
0
9963
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11525
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9858
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.