Hello,
I'm parsing rss feeds however some feeds have what look to be blank images in them (from feedburner). Can somewhere help me out with a preg_replace command to find and remove an image tag structured like:
<img src="http://feeds.feedburner.com/sdfasdfsfd" height="1" width="1"/>
Thanks!
...
I have a Perl script that replaces any Us or Ns at the end of a string with Ts. This program is what I'm trying:
use strict;
my $v = "UUUUUCCNNCCCCNNNCUUUNNNNN";
printf("before: %s \n", $v);
if($v =~ m/([UN]+)$/)
{
my $length = length($1);
substr($v, (length($v) - $length), $length) = "T" x $length;
}
printf(" after: %s \n", $v);
...
In PHP if we need to match a something like, ["one","two","three"], we could use the following regular expression with preg_match.
$pattern = "/\[\"(\w+)\",\"(\w+)\",\"(\w+)\"\]/"
By using the parenthesis we are also able to extract the words one, two and three. I am aware of the Matcher object in Java, but am unable to get similar fu...
Hi,
Im trying to split a string. Simple examples work
groovy:000> print "abc,def".split(",");
[abc, def]===> null
groovy:000>
Instead of a comma, I need to split by pipes, but i'm not getting the desired result.
groovy:000> print "abc|def".split("|");
[, a, b, c, |, d, e, f]===> null
groovy:000>
Of course, my first choice would be...
I'm trying to redirect a series of static URLs, and I want it to work whether or not the trailing slash is present:
/foo/bar ---> /tacos
/foo/bar/ --> /tacos
I've tried the following, and all sorts of variations, but I always get a match only with the trailing slash present:
RewriteRule ^foo/bar?/$ http://url.com/tacos
RewriteRul...
Is there any way to to interpret a string such as "hello\r\n\world" into a string where \r\n has been converted into their actual literal values.
The scenario is that a user types in a regex replacement expression and types \r\n in the UI. That get's escaped but I'd like to get the actual interpreted string from that.
...
Hey,
I'm using NGINX to segment mobile traffic between a mobile WAP/HTML site. Looks like the best way to do this is going to be to check the UA's preference for content by checking the HTTP Accept Header.
A preference for WAP is indicated by the appearance of a 'wap' mimetype in the header before an 'html' or wildcard mimetype.
So a ...
whats the best way to tell if a value in javascript is a single digit. Ive been doing something like
var valAsString = '' + val;
if (valAsString.match(/\d/) {}
clarification: I mean one of 0,1,2,3,4,5,6,7,8,9
Also, should what I have work? Im surprised how many different ways people are coming up with for this.
...
Hi, does anyone know of a good regular expression to remove events from html.
For example the string:
"<h1 onmouseover="top.location='http://www.google.com">Large Text</h1>
Becomes
"<h1>Large Text</h1>
So HTML tags are preserved but events like onmouseover, onmouseout, onclick, etc. are removed.
Thanks in Advance!
...
I have a file with some non-printable characters that come up as ^C or ^B, I want to find and replace those characters, how do I go about doing that?
...
I'm working on the search box for an events website. I've been recording the searches people make and alot of people are entering a {date}+{keyword} combo.
example searches:
jazz 5th november
dj shadow tonight
2nd october live music
so I need to write/find a regex that can match textual dates from within a longer string.
I'm thinkin...
code sameple:
for file in files:
do_something(root+file)
"file" is warned as "redefined symbol", so now I want to replace file to f but I must keep files
usually I use below command:
:%s/file/f/gcI
but it will match files, is there any way to match only whole word, and notice the (root+file) syntax.
...
I'm trying to divide long text in small parts, so that every part is at least N characters and ended with some of the stop punctuation marks (? . !). If the part is bigger than N characters we sttoped when the next punctuation mark appear.
For example :
Lets say N = 10
Do you want lime? Yes. I love when I drink tequila.
This sente...
I'm using php to process rss data, however often feeds have more than image in the description. Can someone help me out with some regex or something to remove all but the first image in the feed? I'd only like to have a max of one image.
Assuming the feed description in is in a variable such as "Sdescription".
CLARIFICATIONS: I've used...
Possible Duplicate:
Regular Expression in C
Does a regex.h exist which i can include?
...
I have a large solution with a lot of lines that I need to replace.
In Visual Studio, you can search and replace with the aid of regular expressions.
I want to replace lines like:
rst.Fields("CustomerName").Value
rst.Fields("Address").Value
rst.Fields("Invoice").Value
To:
row("CustomerName").ToString()
row("Address").ToString()
row(...
I am very puzzled over this error. In a previously functional Pylons app (running on apache/mod_wsgi), Routes has exploded. When I attempt to access my application, no matter what URL I use, I get the Apache "Internal server error" page and the following traceback in /var/log/apache2/error.log.
[Sat Oct 02 2010] WSGI Variables
[Sat ...
I want to apply a search and replace regular expression pattern that work only in a given range of line and column on a text file like this :
AAABBBFFFFBBBAAABBB
AAABBBFFFFBBBAAABBB
GGGBBBFFFFBHHAAABBB
For example i want to replace BBB with YYY in line range 1 to 2 and from column 4 to 6, then obtaining this output :
AAAYYYFFFFBBB...
Hi all.
I have a html page
<a email="[email protected]" href="http://www.max.ru/agent?message&[email protected]" title="Click herе" class="mf_spIco spr-mrim-9"></a><a class="mf_t11" type="booster" href="http://max.ru/mail/corporate/">
I neeed a parse email string
soup = BeautifulSoup(data
string = soup.find("a",{"ema...
So, I'm trying to create a function which does the following:
Receive HTML in a string
Find file paths (in SRC= attributes)
Only replace image urls starting with the domain example.com
Only replace images (jpg, jpeg, gif, png)
Replace the domain of the image with example2.com
Return HTML with image URLs replaced.
Is there an elegan...