I need to match a image url like this:
http://site.com/site.com/files/images/img (5).jpg
Something like this works fine:
.replace(/(http:\/\/([ \S]+\.(jpg|png|gif)))/ig, "<div style=\"background: url($1)\"></div>")
Except if I have something like this:
http://site.com/site.com/files/audio/audiofile.mp3 http://site.com/site.com/f...
Is there anyway easier than this to strip HTML from a string using Perl?
$Error_Msg =~ s|<b>||ig;
$Error_Msg =~ s|</b>||ig;
$Error_Msg =~ s|<h1>||ig;
$Error_Msg =~ s|</h1>||ig;
$Error_Msg =~ s|<br>||ig;
I would appreicate both a slimmed down regular expression, e.g. something like this:
$Error_Msg =~ s|</?[b|h1|br]>||ig;
Is there a...
I'm looking for a bit of code that will:
Given regular expression E, derive the longest string X
such that for every S, X is a substring of S iff S will match E
examples:
E = "a", X = "a"
E = "^a$", X = "a"
E = "a(b|c)", X = "a"
E = "[ab]", X = ""
context: I want to match some regular expressions against a data
store that only sup...
I wrote a regex to fetch string from html, but it seems the multiline flag doesn't work.
this is my pattern and I want to get the text in h1 tag.
var pattern= /<div class="box-content-5">.*<h1>([^<]+?)<\/h1>/mi
m = html.search(pattern);
return m[1];
I created a string to test it. When the string contains "\n" the result is always nul...
string patname ="enter pat name";
patname = "text";
patname = " text pat";
Hi, I want to search "pat" in the above statement using regular expression of visual studio. I tried using Pat{([^a-zA-Z]|$)} this , but it will also search the 2nd line which i really don't want. I want pat to be search inside a string value which starts from "...
I have a asp.net web form where i can can enter an email address.
i need to validate that field with email addresses ONLYin the below pettern :
[email protected]
[email protected]
[email protected]
Please help
...
What is the difference of doing \1 as opposed to $1 if any, or are they interchangeable in all situations.
Example:
s/([a-z]+),afklol/$1,bck/;
#against
s/([a-z]+),afklol/\1,bck/;
They both give the same result but is there any difference?
...
I am writing an XSLT transformation in which I wish to use the Replace function to do a regex match and replace.
However, Visual Studio 2008 reports that
'replace()' is an unknown XSLT function.
The bit of code itself is:
<xsl:otherwise>
<td style="border: solid 1px black; background-color:#00CC66;">
<xsl:variable...
I am trying to search for the substring "abc" in a specific file in linux/bash
So I do:
grep '*abc*' myFile
It returns nothing.
But if I do:
grep 'abc' myFile
It returns matches correctly.
Now, this is not a problem for me. But what if I want to grep for a more complex string, say
*abc * def *
How would I accomplish it using ...
I have two regular expressions that I use to validate Colorado driver's license formats.
[0-9]{2}[-][0-9]{3}[-][0-9]{4}
and
[0-9]{9}
We have to allow for only 9 digits but the user is free to enter it in as 123456789 or 12-345-6789.
Is there a way I can combine these into one? Like a regex conditional statement of sorts? Right n...
I have a string that represents a path to a directory. I want split the string if it is a unix type path or a ms-dos type path.
How can this be done?
For example:
<?php
$a = some_path1/some_path2/some_path3; // unix type path
$b = some_path1\some_path2\some_path3; // MS-DOS type path
$foo = preg_split("something", $a); // what rege...
I am writing a program that will help me find out sites are my competitors linking to.
In order to do that, I am writing a program that will parse an HTML file, and will produce 2 lists: internal links and external links.
I will use the internal links to further crawl the website, and the external links are actually what I am looking f...
I have to two strings that I want to match everything that doesn't equal them, the first string can be followed by a number of characters. I tried something like this, negating two ors and negating that result.
?!(?!^.*[^Factory]$|?![^AppName])
Any ideas?
...
Hi,
I am looking to write something that seems like it should be easy enough, but for whatever reason I'm having a tough time getting my head around it.
I am looking to write a python function that, when passed a string, will pass that string back with HTML encoding around URLs.
unencoded_string = "This is a link - http://google.com"
...
I have some data formated like the following
2009.07.02 02:20:14 40.3727 28.2330 6.4 2.6 -.- -.- BANDIRMA-BALIKESIR
2009.07.02 01:38:34 38.3353 38.8157 3.5 2.7 -.- -.- KALE (MALATYA)
2009.07.02 00:10:28 38.8838 26.9328 3.0 3.0 -.- -.- CANDARLI KÖRFEZI (EGE DENIZI)
2009.07.01 23:3...
I'm having a lot of difficulty matching an image url with spaces.
I need to make this
http://site.com/site.com/files/images/img 2 (5).jpg
into a div like this:
.replace(/(http:\/\/([^\s]+\.(jpg|png|gif)))/ig, "<div style=\"background: url($1)\"></div>")
Here's the thread about that:
http://stackoverflow.com/questions/1066697/rege...
I wanted to write a regex to count the number of spaces/tabs/newline in a chunk of text. So I naively wrote the following:-
numSpaces : function(text) { return text.match(/\s/).length; }
For some unknown reasons it always returns 1. What is the problem with the above statement? I have since solved the problem with the following:-
num...
How can I update this regular expression to find and replace not just "/news/" but "/blog/" as well?
urlLinks = $(this).attr("href").replace(/(\/news\/)/, "$1article/");
It's a simple one. Thanks!
...
Hi,
can somebody tell me how to avoid commented lines when using a regular expression in Visual Studio? I tried ^[^//]* but it deosn't work.
For example, I want to omit following line when I search:
//Hello
...
I need to match the numbers inside a html tag. IE
Sometext<sometag><htmltag>123123</htmltag></sometag>
I need to create a regex that finds the number that is inside the html tag of my choice, in this case the <htmltag>
Thanks everyone :)
...