I am using the following regex to get the src value of the first img tag in an HTML document.
string match = "src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|png))(?:\"|\')?"
Now it captures total src attribute that I dont need. I just need the url inside the src attribute. How to do it?
...
The following is the data I am working on:
__DATA__
Node 1:
98 debug : fill 100
102 debug : fill 104
Node 2:
88 debug : fill 120
152 debug : fill 164
I want to write a regex/(or whatever is appropriate) to capture information from data below Node 1, say '98 : 100', but only after identification of N...
Ok I promise I'll learn regular expressions tonight but right now I need a quick fix.
(Really, I swear I will!)
How do I extract the value of what comes after name= this url:
page?id=1&name=hello
In this case I would be trying to isolate 'hello'.
Thanks!
...
Hi,
I'm trying to write a regex that will match everything BUT an apostrophe that has not been escaped. Consider the following:
<?php $s = 'Hi everyone, we\'re ready now.'; ?>
My goal is to write a regular expression that will essentially match the string portion of that. I'm thinking of something such as
/.*'([^']).*/
in order t...
Hi,
I'm currently building a toy assembler in c# (going through The Elements Of Computing Systems book).
I need to match a very simple pattern, I thought this would be a good time to learn some regex but I'm struggling!
In the following examples I'd just like to match the letters before the '='
M=A
D=M
MD=A
A=D
AD=M
AMD=A
I've ...
I do not know ruby. I am trying to use the following regex that was generated by ruby (namely by http://www.a-k-r.org/abnf/ running on the grammar given rfc1738) in php. It is failing to match in php, but it is successfully matching in ruby. Does anyone see what differences between php's and ruby's handling of regexes that might expla...
I am trying to do a search and replace with regexs.
Suppose I have a foreach(foo1.txt, foo2.txt, foo3.txt, foo4.txt).
And I want to put " around each item in the list.
I thought- from the documentation - that this regex would work
(foo[1-4]\.txt) -> "\&".
But it doesn't. What am I doing wrong?
...
Let's say I have the following three strings:
(section1){stuff could be any character, i want to grab it all}
(section1)(section2){stuff could be any character, i want to grab it all}
(section1)(section2)(section3){stuff could be any character, i want to grab it all}
So if applied regex to my expressions, for the first I would get:
...
Hi, I am trying to build a regular expression to extract the text inside the HTML tag as shown below. However I have limited skills in regular expressions, and I'm having trouble building the string.
How can I extract the text from this tag:
<a href="javascript:ProcessQuery('report_drilldown',145817)">text</a>
That is just a sample o...
Hi all,
I would like to match everything but *.xhtml. I have a servlet listening to *.xhtml and I want another servlet to catch everything else. If I map the Faces Servlet to everything (*), it bombs out when handling icons, stylesheets, and everything that is not a faces request.
This is what I've been trying unsuccessfully.
Patter...
I have some values in a configuration file (XML file) with some values like this:
<IncreamentInSeconds>24*60*60</IncreamentInSeconds>
...
I could put 86400 value there, but it is more descriptive as a calculation expression. This is just a simple example. There are some other expressions as well, but they are all in a kind of calcul...
Hi there, I'm new to regular expressions, and have no clue where to start, it's like a diff language to me. But I need one quick to accomplish a task.
I need to take
http://www.domain.com/folder1/folder2/file_path.txt
and get just
/folder1/folder2/file_path.txt
from it.
Thanks!
...
How can I find and display the word $iperf in a file
The file will look like this
$iperf -c 172.29.38.67 -m -M 64 -i 5 -t 20 -P 10
WARNING: attempt to set TCP maximum segment size to 64, but got 536
WARNING: attempt to set TCP maximum segment size to 64, but got 536
WARNING: attempt to set TCP maximum segment size to 64, but got 536
...
I've noticed a lot of little debates about when to use regex and when to use a built in string function like String.Replace() (.NET).
It seems a lot of people recommend always, always, always using regex whenever you deal with strings at all (besides just displaying them). Is this really best practice or just a wrong impression on my p...
I'm using match() in JavaScript to parse a dates from an RSS feed, I just can't get my head around the correct regular expression to find the date format.
Here's the date:
2009-05-11 16:59:20
And the regular expression so far:
if (dateToParse.match(/^\d\d\d\d-\d\d-\d\d/)) {
dateTimeSeparator = " ";
monthIndex = 0;
...
I get travel confirmations that look like this:
"SQ 966 E 27JUL SINCGK"
= "Airline Space Flight Space BookingClass Space Date_with_Month_as_name Space 3LetterFrom 2LetterTo".
I can chop all this into pieces using a regex to submit it to a website. But the site would expect instead of 27JUL 27/07/2009 or at least 27/07. Is there a way t...
I need to extract all MP3 titles from a fuzzy list in a list.
With Python this works for me fine:
import re
for i in re.compile('mmc.+?mp3').findall(open("tracklist.txt").read()): print i
How can I do that in Ruby?
...
Following is the script for matching regex and storing value in array:
sub b1 {
# print $_;
my @file = @_;
my @value;
my $find = qr/(\s+)([0-9]+)\s([A-Z])\s[0-1].[0-9]+\s->\s([A-Z])\s/;
foreach my $file(@file){
push (@value, $file=~ /$find/) ;
print "\n";
}
...
Is there a way to get a piece of code that is not between quotes (single or double) in javascript with regular expressions?
if i have this string:
'this is a test "this shouldn't be taken"'
the result should be:
'this is a test'
...
I'm using the Validation Application Block from Microsoft. I have a string property which holds a phone number. I have a RegexValidator on it which works pretty well for ensuring only phone number type strings are in the property, but the property should also allow values that are null or an empty string.
Currently the this validator ...