regex 4 « regex « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » regex » regex 4 
The actual number between:  49.950  can be any number of digits before decimal and after decimal. How can I just extract the real/integer number using regex?

1. what is wrong with this simple regex?    stackoverflow.com

I am stuck in a dump:

import re
print re.search('return[^$]+',
                'return to the Treasury of $40 million\nnow!').group(0)
The above ...

2. Regex for URI routing    stackoverflow.com

I'm following up on a question since the question changed Finding the regex for /<region>/<city>/<category>? The answer that works is /(?:[^/]+)/?([^/]*)/?([^/]*) and it outputs city in $1, category in $2 but ...

3. Python inserting backslashes during regular expression    stackoverflow.com

I'm trying to do a regex to substitute in a backslash, but Python seems to be inserting a double-backslash, and I can't make it stop!

>>> re.sub('a', '\\ b', 'a')
'\\ b'
Double backslash ...

4. .NET Regex Equivalent of Python Regex's (?P=previousmatchname)    stackoverflow.com

In Python's implementation of regular expressions you can do the following:

 <(?P<foo>.*)>(.*)</(?P=foo)>
and basically it will look for <this>right here</this> but not <this>right </here>. Basically it allows you to use the ...

5. Traceback for regular expression    stackoverflow.com

Lets say i have a regular expression:

match = re.search(pattern, content)
if not match:
    raise Exception, 'regex traceback' # i want to throw here the regex matching process.
If regular expression ...

6. Get address out of a paragraph with regex    stackoverflow.com

Alright, this one's a bit of a pain. I'm doing some scraping with Python, trying to get an address out of a few lines of poorly tagged HTML. Here's ...

7. Datetime difference to return Days only?    stackoverflow.com

$ cat .t.py 
import re
from datetime import datetime as dtt

oldestDate = dateComp = dtt.strptime('1.1.1001', '%d.%m.%Y')
dateComp = dtt.strptime('11.1.2011', '%d.%m.%Y')
ind = re.sub(" days,.*", "", str((dateComp - oldestDate)))

print ind
print dateComp - oldestDate
$ python .t.py ...

8. What does the python re.template function do?    stackoverflow.com

While using the re module in ipython I noticed an undocumented template function:

In [420]: re.template?
Type:           function
Base Class:     ...

9. Regular expression quantifier    stackoverflow.com

I have a regular expression pattern as follows:

.*\b(?P<core>[A-Z][0-9]?\b.*)(?P<extra>\b[0-9]+[xX][0-9]+.*)?\.png
To match some strings as follows:-
UI SCREEN 5-1 F2 ROUND TAB REFLECTION 224x18px.png
In Python, I get the following result
{u'core': u'F2 ROUND TAB REFLECTION 224x18px', ...

10. how to get an exact directory through os.walk in python    stackoverflow.com

I have a directory that contains directories like /sample1, /sample10, /sample11 etc. when I am using os.walk to access all of them one by one, I am facing some difficulties.

for root, dirs, ...

11. Regarding regular expressions and XML    stackoverflow.com

I have data in XML format. Example is shown as follow. I want to extract data from <text> tag. Here is my XML data.

    <text>
    ...

12. Using a Script or regex to Add "printf" to every functions    stackoverflow.com

In regex or Script (e.g. one written in python) how can I add

printf("TRACING: %s is called\n", __PRETTY_FUNCTION__); 
at entry of all the function definitions, e.g.,
INT4
FunctionNameCouldBeAny (UINT4 ui)
{
 ...

13. How can i invoke a shell command from python which includes regexp?    stackoverflow.com

How can i invoke a shell command from python which includes regexp. i.e: cat filename* I wrote :

    pid = subprocess.Popen(["cat",filename+"*"])
but i am getting an error cat filename* no such ...

14. Correct python re regex    stackoverflow.com

I tried to make regex to validate phone number in format +38(0XX)XXX-XX-XX or 0XX-XXX-XX-XX. My regex is: '^(\+38)*(\(*0\d{2}\)*)[-|\s](\d{3})[-|\s]((\d{2})-|\s)+$'. And it's not matched any way. I reread re syntax a couple of ...

15. Python 2.6 regular expression mechanisms?    stackoverflow.com

I am learning regular expression and I would like to check the mechanisms that python is using. I have the regex:

s = re.findall(ur"\d+\.?\d+", "123,45.567 78").
First I thought that the result was going ...

16. Regular expression in python - help needed    stackoverflow.com

Like many other people posting questions here, I recently started programming in Python. I'm faced with a problem trying to define the regular expression to extract a variable name (I have a ...

17. Python RegEx Meaning    stackoverflow.com

I'm new to python regular expressions and was wondering if someone could help me out by walking me through what this means (I'll state what I think each bit means here ...

18. Python re infinite execution    stackoverflow.com

I'm trying to execute this code :

import re
pattern = r"(\w+)\*([\w\s]+)*/$"
re_compiled = re.compile(pattern)
results = re_compiled.search('COPRO*HORIZON 2000                ...

19. ValueError in decoding json    stackoverflow.com

import json
import urllib
import re
import binascii 

def asciirepl(match):
  s = match.group()  
  return binascii.unhexlify(s[2:])  

query = 'google'
p = urllib.urlopen('http://www.google.com/dictionary/json?callback=a&q='+query+'&sl=en&tl=en&restrict=pr,de&client=te')
page = p.read()[2:-10] #As its returned as a function call

#To ...

20. rearding regex (python)    stackoverflow.com

I have long strings. Like this

{{ name = name
    prodcuer =producer
    writer = writer 
    language = {{english}}
    country ...

21. My regex is not working properly    stackoverflow.com

My regex is not working properly. I'm showing you before regex text and after regex text. I'm using this regex re.search(r'(?ms).*?{{(Infobox film.*?)}}', text). You will see my regex not displaying the ...

22. Re.sub not working for me    stackoverflow.com

I'm trying to get re.sub to replace a pattern specified with a value for example

for lines in f:
    pattern='\${2}'+key[0]+'\${2}'
    re.search(pattern,lines)
this return the line where the ...

23. Python, How should this regex work    stackoverflow.com

I have a regex that should find all the "heading lines" that contain some text that do not end with a period or ? or !:

tit_pat = re.compile(r"([\w ]+?)(?![!?.])\n",re.UNICODE)
res = tit_par.findall(data)
: Example:
...

24. Anyone know how nosetest's -m, -i and -e work?    stackoverflow.com

I am trying to get nosetests to identify my tests but it is not running any of my tests properly. I have the following file structure

Project
    +----Foo/
   ...

25. Regex works in python shell but not in idle    stackoverflow.com

I'm trying to do a regex sub() to change '"' into a space. It works perfectly if I do it in the python shell, but when I try to execute it ...

26. Python regex positive look ahead    stackoverflow.com

I have the following regex that is supposed to find sequence of words that are ended with a punctuation. The look ahead function assures that after the match there is a ...

27. Equivalent from C# matchObject.Value in Python?    stackoverflow.com

I am trying to parse some C# code to Python. There are several regular expression in that code. Everything worked fine so far, but now I've got the following problem: C# Code:

Match ...

28. Python simple regex    stackoverflow.com

So I have a pattern:

hourPattern = re.compile('\d{2}:\d{2}')
And match against the compiled pattern
hourStart = hourPattern.match('Sat Jan 28 01:15:00 GMT 2012') 
When I print hourStart it gives me None. Any help?

29. Python regex with look behind and alternatives    stackoverflow.com

I want to have a regular expression that finds the texts that are "wrapped" in between "HEAD or HEADa" and "HEAD. That is, I may have a text that starts with ...

30. python, codecs, file.writelines(), UnicodeDecodeError    stackoverflow.com

Do not know how to resolve the UnicodeDecodeError: I am not able to write text to file --> UnicodeDecodeError about character â = '0xe2'. 1) â = '0xe2' character for sure ...

31. Python regex negating metacharacters    stackoverflow.com

Python metacharacter negation. After scouring the net and writing a few different syntaxes I'm out of ideas. Trying to rename some files. They have a year in the title e.g. [2002]. Some don't have ...

32. Regular expression tricks in python    stackoverflow.com

I have a lines in file as:

keyword = NORTH FACE
keyword = GUESS
keyword = DRESSES
keyword = RALPH LAUREN
My Code is:
keyword=re.findall(r'ke\w+ = \S+',s). 
This prints only
NORTH
GUESS
DRESSES
RALPH
But I need regex to handle and print
NORTH ...

33. handling '++' sign in python regex    stackoverflow.com

i have a list of words
i am creating a list of regex objects based on this list of words

import re
word = 'This is word of spy++'
wl = ['spy++','cry','fpp']
regobjs = [re.compile(r"\b%s\b" % ...

34. How to do this using regex in python.    stackoverflow.com

A bit confused trying to do a string match that accepts this: Lets say a string S = "Download" Here, S can be "Download" or "DOWNLOAD" or "DoWNload". Thus, any character in ...

35. Vim: Editing the python.vim syntax file to highlight like Textmate    stackoverflow.com

I'm trying to edit the python.vim syntax file to duplicate the syntax highlighting for python in Textmate. The attached image illustrates the highlighting of function parameters which i'm struggling to achieve.

36. quick regex question    bytes.com

37. Regexp parser and generator    bytes.com

On Nov 4, 1:34*pm, George Sakkis >parse_rx(r'i (love|hate) h(is|er) (cat|dog)s?\s*!+') > Regex('i ', Or('love', 'hate'), ' h', Or('is', 'er'), ' ', Or('cat', 'dog'), Optional('s'), ZeroOrMore(r'\s'), OneOrMore('!')) > Given such a structure, I want to create a generator that can generate all strings matched by ...

38. Python Regex Question    bytes.com

I need to extract the number on each

 49.950  ######.#### 

39. Regex Python    dreamincode.net

import re # File contents # Man:test # Other Man:test # Man:test # Other Man:test # Compile the string to find # In this case, if the line begins with "Man" to_find = re.compile('^Man') # Open the file for reading with open('c:\sketch.txt', 'r') as f: # Read line by line for line in f: # Try to match compiled regex if ...

40. Python: Need help cycling through regex results    dreamincode.net

Hello everyone! I am working on a Python script that does the following: Connect to an ftp site Change to the appropriate directory Get a listing Use a Regex to pull out just the file names from the listing Cycle through the file names and download each one Here is the code I have so far: #!/usr/bin/env python import ftplib import ...

41. Beautiful Soup & regex    python-forum.org

def soapParserExtractToFile(self, htmlElementToView, endingAncorStr, magicWord, fileName): filePtr = open(fileName, "w") soup = BeautifulSoup(self.strippedString, convertEntities=BeautifulSoup.HTML_ENTITIES) htmlSections = soup.findAll(htmlElementToView) for htmlSection in htmlSections: print htmlSection searchVal = re.search(magicWord,htmlSection) ##<- ERROR - TypeError: 'expected string or buffer' ...

42. regex puzzle    python-forum.org

43. Simple regexp question    python-forum.org

def foo(l1): l2 = "boar bear pig bird fish monkey" for item in l1: pat = str(r"\b" + item + r"\b") result = re.search(pat, l2) if(result != None): ...

44. python regex behavior    python-forum.org

1) Bill wrote:Is it clear that the re matched what you asked for (not what you intended? The pattern '[1]' says "match a '1' at the beginning of the subject string", and indeed it did. To be precise, the pattern '[1]' says to look for a '1' anywhere in the string. However, the match() function is defined to look for the ...

45. REGEX    python-forum.org

46. regex problem    python-forum.org

47. Need help with a simple regex    python-forum.org

48. Python Regex    python-forum.org

I have been playing with python regex for a bit now and can't figure out how to, or if it is possible to find this regex. As an aside project and getting familiar with python i am using my webserver with several pages with images, i am using urllib2 to get the html and then i want to use a regex ...

49. quick regex help please [Solved]    python-forum.org

>>> b 'to be possible to say to be able to say to say to call (i.e. to give a name) if one were to speak of ..., then certainly if it were the case that ..., then certainly if it were a ..., then certainly phrase used to indicate the inevitability of what follows it (based on what precedes it) ...

50. using regexp 're.sub'    python-forum.org

def app(): xxx = [{'title':'Mhello', 'pubDate': '3GMT'}, {'title':'Myes', 'pubDate':'4GMT'}] match = '^M' replace = '' for item in xxx: item['title'] = re.sub(match, replace, item['title']) print xxx

51. Another Simple Regex Problem    python-forum.org

>>> import re >>> sample = ["Who's your daddy? For, of, you, hiiiii my name is .2 DOESNT MATTER 4.8", ... "No way. Are you serious? This doesn't make any sense. 0.5 Whatever 0.8", ... "One more try... ...

52. Why do this fail sometimes? regexp?    python-forum.org

import re,sys,os for infile in range(1, len(sys.argv)): #print (infile) for line in open(sys.argv[infile], 'rb'): if "RegistryName" in line: match = re.search(b'(?<=Info).+(?=RegistryName)', line) filepath = os.path.basename(sys.argv[infile]) ...

53. regex    python-forum.org

54. REGEX Help    python-forum.org

Hi, I would like to use a regex to do the following: I am given a list of strings such as: abc01 - [def02] - ghi03 - jkl04 Each string will have a different number of items. Some will have brackets around and some will not. Can someone help me with a regex match that will consist solely of items not ...

55. stuck with a complex regex    python-forum.org

Well, you have several possibilities (and you will hate your live with all of them): If your regular expression dont contain any spaces, I would split the whole string and test the first block/token against the first available regex. If that first regex misses I will test it against the next regex in line. If it hits I go ahead to ...

56. Sequence Allignment (Regex)    python-forum.org

Hi Guys, I've just started programming with python and trying my first "bigger" Program. the program should match a short DNA sequence onto every possible match in a long DNA sequence. I will be using the uipac coding as in the NA_Class dictionary by now my program aligns perfectly and tells me which index it has on the dna. now i ...

57. Reverse regex    python-forum.org

Thanks Bill, I just ran through a couple of scenarios with the code that you posted, and all of my results have been the same, it is always pulling the first match by reading left to right rather than pulling from right to left. For this instance I could hard code the split locations, but for other OID's that do not ...

58. [SOLVED] RegExp how-to: {A|B}C    python-forum.org

I want to search for strings of the form AC or BC, and my C is long (and really there's more than just A and B), so I would be very happy to factor the expression as in the subject line. But I haven't been able to figure out a way to do that. Suggestions? Thanks!

59. How to pass a regexp to a defined function?    python-forum.org

import re,urllib2,urllib def htc(m): return chr(int(m.group(1),16)) def urldecode(url): rex=re.compile('%([0-9a-hA-H][0-9a-hA-H])',re.M) return rex.sub(htc,url) url='http://www.****.com/video564055/****' def getURL(url): opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) opener.addheaders = [('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 ...

60. Solve this regex (its complicated)    python-forum.org

I've been trying to match some incoming strings from a mud(text based rpg) and I'm having some trouble. I need a regex that will match the tag in these strings. You can have a separate regex per sentence to match the surrounding text. You would stomp into the ground. would be easy, but is it even worth the ...

61. Wicked easy Regex question    python-forum.org

import re text = '''Hi, I need a regular expression to find a line, in a file. The string I need to obtain is like this 1 1.2 3.4 4.5 OR 2.2 4.5 4.4 3.2 Meaning the first value can be an int (no decimals) OR a floating point value. Any tips? Thanks.''' regex = re.compile('^\d+\.?\d*') for line in text.split('\n'): ...

62. regexp question    python-forum.org

Thank you for the reply waz. I thought about this, but my problem is a bit more general. I have a string containg n-words and another string containing m words. I want to find all the words of m in n such that the string in m is not m. I know that is confusing. Here is another example: string = ...

63. easy regex question    python-forum.org

Hi I need to use a regex to find this string in a file. I am using a for loop to check in line in a file object, f Here is the string I need a regex for 10 20 | a = 0 So two integers, a pipe, then a character followed by and equals sign and another integer. I ...

64. Regex question    python-forum.org

Micseydel wrote:Or, more simply, Code: Select all re.findall('(word[0-9]+=[0-9]+)', x) True for this example. When I built my pattern I chose to collect the two portions of interest in separate groups because I had thought to modify it in a later posting to allow space characters on each side of the equal sign. Collecting in two groups and reassembling with string formatting ...

65. RegEx Help    python-forum.org

I am a newbie and I am playing around with Python to make a program to convert an post fix expression to infix. In order to check if my input string is a valid one like : 4.5 5 + 6 * 7 \ , I need to use regex. Below is what I wrote for my regex using the re ...

66. Regex for CVS log    python-forum.org

67. regex and if statements    python-forum.org

for pat in [r'

  • .*target="_blank">([^\<]+)', r'
  • ([^\s]+)\s\[']: mo = re.search(pat, line) if mo: aliases.append(mo.group(1)) break # At this point either a match was found and the appropriate group # was appended to aliases or no match was ...

  • 68. webscraping & regex    python-forum.org

    thanks for that couple questions, what does the "re.S" identifier do? and how do i access the data in row_regex to parse it into the information i am looking for? in my previous code i was able to type something like "m[12]" to access an element of the search results, but if i try that for "row_regex" it gives me: TypeError: ...

    69. Newbie trying to use regex to pull info from file    python-forum.org

    #!/usr/bin/python env #Filename snort_search.py import re myfile = open('snort_rules/snort/exploit.rules') rules = myfile.readlines( ) myfile.close #main data = raw_input("\nPlease enter your search criteria: ") pattern = re.match("(\w+\w+\W+\w+\W+\W+\d+/)", data) if data == rules: print pattern else: print "Could not find a match"

    70. Simple regex question?    python-forum.org

    71. regex question - directory compare    python-forum.org

    72. Absolute Beginner, looking for help with Regex.    python-forum.org

    I'm trying to split a table [http://quiddity.cc/rachel/diet/wwfoods.htm] and put the data into a MySQL database, I asked around on my MSN list and people said that it would be somewhat easy to do in Python, and I've used C# before - and figured Regex would be the best way to go about splitting the data. Problem is; I don't know any ...

    73. Another basic regex question    python-forum.org

    >>> a = re.compile('\b\d{4}[.]\d{2}[.]\d{2}\b') >>> d = a.match("Feb 18, 2009 - 02:30 PM EST / 2009.02.18 1930 UTC") >>> print d None >>> a = re.compile('\d{4}[.]\d{2}[.]\d{2}') >>> d = a.match("Feb 18, 2009 - 02:30 PM EST / 2009.02.18 1930 UTC") >>> print d None >>> e = re.compile('\b\d{4}\s(?:UTC)') >>> t = e.match("Feb 18, 2009 - 02:30 PM EST / 2009.02.18 1930 ...

    74. regex 101 help    python-forum.org

    75. RegExp problem    python-forum.org

    RegExp problem by pybee Sun Feb 15, 2009 7:33 pm I have a text file with these kinds of lines in it: Code: Select all Radio Source Precession Program ...

    76. Regex problem i think    python-forum.org

    Hey guys, well i just started learning python recently, i have about 3 years of experience in c/++/#. I'm having a certain problem, here's my example. basically, i'm reading the html from a page, lets say "www.test.com" and i store everything in a variable like: Code: Select all import urllib2 page = urllib2.urlopen('http://www.test.com').read() so i have everything stored in "page", and ...

    77. ReGex help    python-forum.org

    hey guys, I've used regular expressions before, but they're still intimidating at times. I'm working with a script that will scrape a bunch of college football scores. I've created a list with them all in it, each element of the list has the date, team name, score, other team's name and their score. here's piece of the larger list, called testlist: ...

    78. omitting a result from a regex    python-forum.org

    omitting a result from a regex by RawnNiven Tue Sep 30, 2008 5:37 am Hi All, I'm running a regex on a large file that contains results from some tests and I want to gather the information on what has passed and what has failed, which, so far I've managed to do. However, there is a line that fits the ...

    79. regex help    python-forum.org

    80. regex question    python-forum.org

    thanks, but here's a true beginner's qu: if i did pattern = re.compile(">[A-z]+") result = re.findall(pattern,string) I'd get results like >Los and >Houston But why is it when you do this: print re.findall('(.*?)', string) you dont get the before each of the results and after the result? Lastly... (.*?) I see that combo a lot, but it ...

    81. regex question    python-forum.org

    why do the two following patterns return different results? pattern = re.compile(">[0-9]+|>[.][0-9]+|>[0-9][.][0-9]+") finds: [>8', '>8', '>1', '>3', '>0', '>0', '>0', '>42', '>34', '>26', '>23', '>8', '>37', '>54', '>4', '>1', '>.218', '>1', '>1', '>1', '>0', '>0', '>0', '>0', '>6', '>5', '>0', '>0', '>0', '>1', '>8', '>0', '>1', '>.238', '>6', '>5', '>0', '>0', '>0', '>1', '>8', '>1', '>0', '>0', '>6', '>0', '>6', '>5', ...

    82. simple regex question    python-forum.org

    i'm scraping a page with a lot of data in it and i want both data that is like 5, 10, 231 and things like .520 or .013 i wanted to do: pattern = re.compile("[0-9]+|.[0-9]+") But the "." matches any non newline character, if i remember correctly...so how do i search for an actual decimal point? thanks

    83. Need to change a regexp in Python script    python-forum.org

    Hi again, I didnt quite understand the last reply? The number of columns is always the same in the logfile. And I want to match only the third column from the end. In reply to the previous reply: No, some columns are not enclosed by double-qoutes. Would I need to include all columns in the logfile lines in my reg exp ...

    84. Regex sub question    python-forum.org

    85. regex question    python-forum.org

    86. regex return true or false    python-forum.org

    87. regexp?    python-forum.org

    If this html document is realy strict about enclosing the information in tags and not nesting tags i would do something like this Find first , this is the start of information from that position find first , this is the end of information substring from start to end, place in list for ...

    88. Python 3.0 Bytes: can we use regex?    python-forum.org

    I heard that in Python 3.x, there'll be a new built-in type called Bytes, and the old 8-bit String has been kicked out. My questions are: 1. Can we use regex on the new Bytes? For example, I have a binary file, and I want to search for a pattern inside it. In Python 2.x, I can use regex without any ...

    89. REGEX question    python-forum.org

    is there a way to tell regex to get one pattern, but not the other? For example I'm scrapping a lot of things like look like ADEG or KH or PHEK (essentially all capital letters 1 - 5 characters long) But every now and then they'll be some problem childs that look like: LK.T or NDE.RE or AWHOLEWORD So is there ...

    90. scraping/regex problem    python-forum.org

    >>> for line in urllib2.urlopen("http://biz.yahoo.com/research/earncal/today.html"): ... if "After Market" in line: ... print back1 ... print back2 ... back2 = back1 ... back1 = line ... name=Keywords xmlns="" align=center>N/A

    Conference
    Call
    ABG SUNDAL COLLIER ASA

    91. python regexp - grabbing data from webpages    python-forum.org

    hello all, i'm trying to grab the text from a webpage, minus the tags and other formatting/metadata (including what's between , ,

    , etc). basically, i want to grab everything you'd see if you were using lynx to view a page. i was thinking of doing this with regexps, but i'm having trouble coming up with a regexp that works. are ...

    92. begining with Regex    python-forum.org

    If I have a file lets call it stuff.txt and I want to scan it for different elemants using regular expressions, how do I get Regex to look at a file? If i were to put stuff.txt as a string then I think I'd do something like say.... string = "whatever whas in stuff.txt" if re.findall("[a-z][0-9]", string) print string Thanks.

    93. import regex    python-forum.org

    94. question on extending the regex object    python-forum.org

    question on extending the regex object by drkstr Tue Oct 31, 2006 1:47 pm I'm trying to get my mind around regex objects using re.compile. I haven't been able to figure out the answer to this question from the python reference docs or from Text Processing in Python by David Mertz. Perhaps someone can point me in the right direction? ...

    95. Regex help    python-forum.org

    Code: Select all regex = '''(?x) (?#turn on the verbose flag, so i can space out this mess.) ATG (?#all matches must begin with this sequence.) ( (?#a group of possibilities...) C[ATGC]{,4} (?#a C followed by ...

    96. RegEx help    python-forum.org

    Hey pyfolks, is there a better way of doing this? im just trying to replace the xml encoded string parts with their corresponding regular parts. gt = re.compile('>') lt = re.compile('<') amp = re.compile('&') quot = re.compile('"') apos = re.compile(''') string = gt.sub (">", string) string = lt.sub ("<", string) string = amp.sub ("&", string) string = apos.sub("'", string) string = ...

    97. RegEx Problem ...    python-forum.org

    I am trying to convert some PHP code I made into Python. My problem is that the regex wont match or w/e. Here is what I am trying to convert Code: Select all

    98. Having a problem with printing results not found by regex    python-forum.org

    Having a problem with printing results not found by regex by suffa07 Tue Jun 21, 2011 6:37 am In the code below, the program is getting string data from the user and converting it to ascii and hex and searching all .log and .txt files in a certain directory for the string in plain string, hex, and ascii values. The ...

    99. Python regex problem    python-forum.org

    After playing with it I see that there are words for which it doesn't work. This is the entire code with wrong examples included: Code: Select all import re def get_word_and_punctuation(my_string): '''Receives a string and returns the word part and the punctuation part. Examples: 'one.' ...

    100. regexp difficult task    python-forum.org

    Hello, I have one problem with regexp. My regexp is like: "(?:Page\s+)?(?P\d{1,2})(?:\s+page)?" It should match against strings like like "Page 233" or "2 page". If it matches, I am able to find exact number of a page by doing .group('pageNo'). That's possible, because I created a naming group. The problem is, that this regexp matches also simple strings like '23' or ...

    java2s.com  | Contact Us | Privacy Policy
    Copyright 2009 - 12 Demo Source and Support. All rights reserved.
    All other trademarks are property of their respective owners.