I have code that roughly looks like this (the entire code is a bit too long to copy here):
import re
from subprocess import Popen, PIPE
goodOutput = re.compile(r'\S+: 0x[0-9a-fA-F]{8} \d \d\s+->\s+0x[0-9a-fA-F]{8}')
p = Popen(['/tmp/myexe', param], stdout=PIPE, stderr=PIPE, cwd='/tmp')
stdout, stderr = p.communicate()
ret = goodOutp...
In Ruby both expressions seem to do similar things:
'it' =~ /^it$/ # 0
'it' =~ /\Ait\Z/ # 0
# but
/^it$/ == /\Ait\Z/ # false
So I an wondering what is the difference between ^-\A and $-\Z and how to choose which one to use?
...
Possible duplicate: Regular expressions in J2ME
Hi !
How can I use regular expressions in microedition?
Thanks in advance
...
I have to file that has different types of lines. I want to select only those lines that have an user-agent. I know that the line that has this is something like this.
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
So, I want to identify the line that starts with the string "Us...
I'm trying to figure out how to better parse lines of text that have values that look like this:
line1
'Line two' fudgy whale 'rolly polly'
fudgy 'line three' whale
fudgy whale 'line four'
'line five' 'fish heads'
line six
I wish to use a single regular expression to display the desired output. I already know how to kludge ...
hi, i have a document and i want copy group. start document and end document e.g.
bold*Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vitae dapibus tortor. Duis odio massa, viverra quis vestibulum nec, tincidunt ac tellus.*bold Ut id enim sapien, ut varius dolor. Curabitur ipsum dolor, consectetur quis fermentum ut,...
I'm trying to wrap words and words sequence from a given list with preg_replace. It almost works, but there are some use cases it doesn't and I can't figure it how.
For instance I do this:
// sort by descending length
usort($this->_keywords, function($a,$b){return(strlen($a)<strlen($b));});
// wrapper is -%string%-
fo...
Hi friends,
I have following string.
?page=1&sort=desc¶m=5&parm2=25
I need to check whether the enter string url is in strict format except variable value.
Like page=, sort=, param=, param2.
Please suggest regular expression.
Thanks
...
Hey guys, I'm having a few issues with using PCRE to make a irc nickname format correctly. I'm not good with PCRE, and I'd love some suggestions from those of you who do use PCRE / regex. :)
I'm currently using this expression: /^([^A-Za-z]{1})([^A-Za-z0-9-.]{0,32})$/
I'm using it as such: preg_replace($regex, $replaceWith, $content)
I...
Require regular expression for matching below string
'/test_25-5?page=5'
...
I need some help with a simple pattern matching and replacement exercise I am doing?
I need to match both of the following two strings in any string in a given context and it is expected that both patterns are to exist in a given supplied string.
1) "width=000" or "width=00" or "width=0"
2) "drop=000" or "drop=00" or "drop=0"
The val...
Hi all
How can I replace 2 known strings separated by an unknown string using a regexp?
For example, I might have
known_string_1 blah_random text blah known string 2
I know I need some sort of wildcard expression between the two known strings in the refexp, but being a regexp nooblet I have no idea what to use. The unknown string...
I have this url: http://localhost/zina/Artist%20One%20Demo?l=8&m=10&c
And it needs to become: http://localhost/?p=Artist%20One%20Demol=8&m=10&c&option=com_zina&Itemid=82
I am using this to rewrite the url:
RewriteRule ^zina/(.*)?(.*)$ /?p=$1&$2&option=com_zina&Itemid=82 [L,R]
However, I wind up with urls that ...
I have a list of strings. Some of them are of the form 123-...456. The variable portion "..." may be:
the string "apple" followed by a hyphen, e.g. 123-apple-456
the string "banana" followed by a hyphen, e.g. 123-banana-456
a blank string, e.g. 123-456 (note there's only one hyphen)
Any word other than "apple" or "banana" is invalid....
I receive e-mails at least once a day with price changes. I am attempting to automate the recording of the data. I am fairly new to regex and now more confused than I was 5 hours ago.
Here are some sample lines to parse. Note that the time format is not always the same:
Effective 00:01AM, 10/13/10, PRICES WILL BE AS FOLLOWS UNLESS OT...
I'm building an app with several languages.
test.com/ -english index
test.com/ca - canadian english index
test.com/canada-promo - english version of canada promo page
test.com/ca/canada-promo - canadian english version of promo page
how would I filter this?
sorry about that. there are actually 4 languages (/fr/ and /es/). I want to b...
I have the problem i want to get these numbers, BUT only when then dont come an "foo"
Example:
"12:13 Foo" (no)
"12:22 Bla" (yes)
i have the Regex: (\d+):(\d+)
and dont know what to do that it dont select strings with the "Foo" after the digits
...
I have a directory of 9 images:
image_0001, image_0002, image_0003
image_0010, image_0011
image_0011-1, image_0011-2, image_0011-3
image_9999
I would like to be able to list them in an efficient way, like this (4 entries for 9 images):
(image_000[1-3], image_00[10-11], image_0011-[1-3], image_9999)
Is there a way in python, to re...
I have this url:
http://dev.example.com//zina/Artist%20One%20Demo?l=7&img=artist%20pic%20can%20can%20be%20named%20anything.jpg&it=full
And it's being rewritten to this:
http://dev.example.com/?p=Artist%20One%20Demo&option=com_zina&Itemid=82&l=7&img=artist%2520pic%2520can%2520can%2520be%2520named%2520anything.jpg&...
Hi,
I have to read in a file that contains a number of coordinates. The file is structured in the following way:
X1/Y1,X2/Y2,X3/Y3,X4/Y4
Where X and Y are positive integers. To solve this problem I want to use a regex (I think this is in general a good idea because of minimal refactoring when the pattern changes).
Therefore I have d...