I have a mako template that looks something like this:
% if staff:
<!-- begin staff -->
...
<!-- end staff -->
% endif
That way if I pass the staff variable as being True, those comments should appear. I'm trying to test this by using a regular expression that looks like this:
re.search('<!-- begin staff -->.*<!-- end st...
I have a couple email addresses, '[email protected]' and '[email protected]'.
In perl, I could take the To: line of a raw email and find either of the above addresses with
/\w+@(tickets\.)?company\.com/i
In python, I simply wrote the above regex as '\w+@(tickets\.)?company\.com' expecting the same result. However, support...
Hello All,
I would like to display files that contain more than one expression and exclude files that do not have all expressions.
Any ideas?
Thanks!
...
I have this regex code in python :
if re.search(r"\{\\fad|fade\(\d{1,4},\d{1,4}\)\}", text):
print(re.search(r"\{\\fad|fade\((\d{1,4}),(\d{1,4})\)\}", text).groups())
text is {\fad(200,200)}Épisode 101 : {\i1}The Ghost{\i0}\Nv. 1.03 and read from a file (don't know if that helps).
This returns the following:
(None, None)
When I ...
Though .htaccess, I want to redirect /page/var1/var2 to ./page.php?var1=var1&var2=var2. This is very easy BUT I want to make it so /page/var1 also redirects to ./page.php?var1=var1 (without having the var2). The only way I'm doing this is:
RewriteRule page/(.*)$ ./page.php?var1=$1
RewriteRule page/(.*)/(.*)$ ./page.php?var1=$1&var2=$2
...
Ok. Given the example of:
http://example.com/news/3226-some-post-title.html
I'm trying to get the 3226. This regexp: http:\/\/interaktywnie.com\/newsy\/(.*).html
doesn't seem to work. Please help.
Thanks.
...
What's a regular expression that validates if a string is pandigital (containing all digits from 1 to 9 exactly once)?
For example:
123456789
891364572
But not:
11234556789
25896471
I know how to do this without regex but I was unable to form a regex for it.
Thanks.
This is not homework.
...
Before we start, strip_tags() doesn't work.
now,
I've got some data that needs to be parsed, the problem is, I need to get rid of all the HTML that has been formated very strangely.
the tags look like this:
(notice the spaces)
< p > blah blah blah < / p > < a href= " link.html " > blah blah blah < /a >
All the regexs I've been tr...
What regular expression can identify double quotes outside of HTML tags (which already will be validated) to escape them to "?
...
What RewriteRule (using .htaccess/mod_rewrite) should I use to redirect http://example.com/blog/ (with www or without) to http://blog.example.com/ ?
I'm using the following, but getting a redirect loop:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/blog/ [L,R=301]
Rewrite...
I'm trying to parse various info from log files, some of which is placed within square brackets. For example:
Tue, 06 Nov 2007 10:04:11 INFO processor:receive: [someuserid], [somemessage] msgtype=[T]
What's an elegant way to grab 'someuserid' from these lines, using sed, awk, or other unix utility?
...
Currently I am using this one ( edit: I missed to explain that I use this one for excluding exactly these words :p ):
String REGEXP = "^[^(REG_)?].*";
but matches (exluding) also ERG, EGR, GRE, etc... above
P.S.
I removed super because it is another keyword that I must filter, figure an array list composed with more of the foll...
I am trying to extract the string from a file having following pattern within a line
>------ </
The ----- represents can be any variable length string. The start pattern within a line is > and end pattern </.
Using regex of VIM is command line search possible? and if so could that be printed?
Or will have to write a script?
I am a ...
According to this guide, I can use NSPredicate to do regex matching on strings, i.e., the perl equivalent of $my_string =~ m/[some regex]/
But can I do regex replace, i.e. the equivalent of this perl expression: $my_string =~ s/[pattern]/[replacement]/g ?
...
Hello,
I am looking for a regular expression to determine when any of the values in a 32-bit hex value is non-zero.
The data patterns look like 0x00000000 and I want to know when any of the digits is non-zero. For example, if 0x00001000 or 0x10000000 or 0xB000000 would be capture by the regular expression, but not a 0x00000000 patter...
I'm working on a tool that parses files for CSS style declarations. It uses a very complicated regular expression that, besides the expected performance issues and a few minor bugs that aren't affecting me for now, is doing everything I'd like it to do except for one thing.
I have it matching all combinations of element names, classes,...
I'm trying to regexp a line from a webpage. The line is as follows:
<tr><td width=60 bgcolor='#ffffcc'><b>random Value</b></td><td align=center width=80>
This is what I tried, but it doesn't seem to work, can anyone help me out? 'htmlbody' contains the html page and no, I did not forget to import 're'.
reg = re.compile("<tr><td width...
I have an NSString with web links in it. I need to find all web links in the string starting with http://. What is the best way to do this?
...
I have the following:
$reg[0] = '`<a(\s[^>]*)href="([^"]*)"([^>]*)>`si';
$reg[1] = '`<a(\s[^>]*)href="([^"]*)"([^>]*)>`si';
$replace[0] = '<a$1href="http://www.yahoo.com"$3>';
$replace[1] = '<a$1href="http://www.live.com"$3>';
$string = 'Test <a href="http://www.google.com">Google!!</a>Test <a href="http://www.google.com"...
On the one hand, there are many people who seem to see regular expressions as the holy grail. Something that looks so complicated just must be the answer to any question. They think that every problem is solvable using regular expressions.
On the other hand, there are also many people who try to avoid regular expressions at any cost. ...