473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help with regular expression

Rob
Hello all,

I have the folowing string
"url(http://www.somelocation/anaywhere/image.jpg)" stored in the variable
str_image
and I want to extract the string between the brackets.
I have

ar_match=str_image.match("url([.]*)");

it returns
0=url
1=

How do I get this to work?

thanks in advance Rob

Jul 20 '05 #1
4 1567
Rob wrote:
Hello all,

I have the folowing string
"url(http://www.somelocation/anaywhere/image.jpg)" stored in the
variable str_image
and I want to extract the string between the brackets.
I have

ar_match=str_image.match("url([.]*)");


I'd do:

var strURI = str_image.replace(/^url\(|\)$/ig, "$1");
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: www.andrewu.co.uk/about/contact/
Jul 20 '05 #2
Rob

"Andrew Urquhart" <re***@website.in.sig> schreef in bericht
news:Gh***************@newsfe2-gui.server.ntli.net...
Rob wrote:
Hello all,

I have the folowing string
"url(http://www.somelocation/anaywhere/image.jpg)" stored in the
variable str_image
and I want to extract the string between the brackets.
I have

ar_match=str_image.match("url([.]*)");


I'd do:

var strURI = str_image.replace(/^url\(|\)$/ig, "$1");
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: www.andrewu.co.uk/about/contact/

From now on I do the same ... ;-)

thanks Rob
Jul 20 '05 #3
rh
"Rob" <reply_@news_group.please> wrote in message news:<S1******************@amsnews05.chello.com>.. .
"Andrew Urquhart" <re***@website.in.sig> schreef in bericht
news:Gh***************@newsfe2-gui.server.ntli.net...
Rob wrote:
Hello all,

I have the folowing string
"url(http://www.somelocation/anaywhere/image.jpg)" stored in the
variable str_image
and I want to extract the string between the brackets.
I have

ar_match=str_image.match("url([.]*)");


I'd do:

var strURI = str_image.replace(/^url\(|\)$/ig, "$1");
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: www.andrewu.co.uk/about/contact/

From now on I do the same ... ;-)

thanks Rob


Note that the "$1" is extraneous in the replacement string, since
there are no capturing parentheses in the RegExp literal (not that any
are desired in this case).

The slight modification:

var strURI = str_image.replace(/^url\(|\)$/ig, "");

seems likely to be as Andrew intended to present.
Jul 20 '05 #4
rh wrote:
The slight modification:

var strURI = str_image.replace(/^url\(|\)$/ig, "");

seems likely to be as Andrew intended to present.


Oops, $1 is a force of habit, thanks rh :-)
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: www.andrewu.co.uk/about/contact/
Jul 20 '05 #5

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

Similar topics

9
by: Steve | last post by:
Hello, I am writing a script that calls a URL and reads the resulting HTML into a function that strips out everthing and returns ONLY the links, this is so that I can build a link index of various...
5
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,...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
6
by: JohnSouth | last post by:
Hi I've been using a Regular expression to test for valid email addresses. It looks like: \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* I've now had 2 occassions where it has rejected and email address...
3
by: Joe | last post by:
Hi, I have been using a regular expression that I don’t uite understand to filter the valid email address. My regular expression is as follows: <asp:RegularExpressionValidator...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
6
by: deepak_kamath_n | last post by:
Hello, I am relatively new to the world of regex and require some help in forming a regular expression to achieve the following: I have an input stream similar to: Slot: slot1 Description:...
14
by: Chris | last post by:
I need a pattern that matches a string that has the same number of '(' as ')': findall( compile('...'), '42^((2x+2)sin(x)) + (log(2)/log(5))' ) = Can anybody help me out? Thanks for any help!
3
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.