0
votes
3answers
14 views
Searching and extracting WH-word from a file line by line with Python and regex
I have a file that has one sentence per line. I am trying to read the file and search if the sentence is a question using regex and extract the wh-word from the sentences and save them back into ...
1
vote
0answers
58 views
How to split string of biographical info into different dictionaries using regex, in Python?
Recently I got my hands on a research project that would greatly benefit from learning how to parse a string of biographical data on several individuals into a set of dictionaries for each individual.
...
-1
votes
2answers
41 views
Regex for the dot character?
I am trying to detect a 'bullet' character followed by some text. For example:
• This is some text here
Can someone tell me what is the regex to detect the 'bullet' character • in python? What is ...
1
vote
1answer
53 views
python re.compile and split with ÆØÅ charcters
I am very new in Python.
I do have a file with a list of words. They contain Danish letters (ÆØÅ) but the re.compile do not understand theses characters. The function split the words by each ÆØÅ. The ...
3
votes
1answer
25 views
processing urls with hashes like jsbin
jsbin, on browsers which do not support (window.history && window.history.pushState) modify the url via window.location.hash = data.edit; (details here).
This creates urls like this
...
0
votes
2answers
14 views
require minimum length of a variable in a django url
This bit from my urls.py requires a nine character value...
(r'^launch/(?P<app_id>[0-9A-Za-z]{9})/*', 'mysite.views.launch_app'),
How do I change this so it requires a minimum nine character ...
1
vote
3answers
56 views
Replace sequence of same characters
What is the fastest way in Python to replace sequence of 3 and more same characters in utf-8 text?I need to replace sequence of 3 and more same characters with exact 2 characters.
I.e.
aaa -> aa
...
1
vote
3answers
56 views
regex to strict check numbers in string
Example strings:
I am a numeric string 75698
I am a alphanumeric string A14-B32-C7D
So far my regex works: (\S+)$
I want to add a way (probably look ahead) to check if the result generated by ...
1
vote
2answers
43 views
Does python re (regex) have an alternative to \u unicode escape sequences?
Python treats \uxxxx as a unicode character escape inside a string literal (e.g. u"\u2014" gets interpreted as Unicode character U+2014). But I just discovered (Python 2.7) that standard regex module ...
0
votes
6answers
52 views
how to write regex for a price expression?
Expression is : "price(might contain comma) EG"
Examples:
40 EG
OR
4,657 EG
OR
4,352,345 EG
I want one string regex I should use for all of these cases.
-3
votes
0answers
45 views
how to get python comment lines count in ruby on rails using regular expressions in ruby [closed]
I need the count of comment lines in pythone code using ruby script with regex. I need the count of block of comments too.
For eg:
"""
This is block
of comments
"""
Thanks for the help in advance
-1
votes
0answers
53 views
Python: Text to HTML
Trying to convert a text document into a html document. Small Example:
''Heading''
Becomes:
<h1>Heading</h1>
I can't get the backslash on the last part of the HTML tag.
P.S. Using ...
0
votes
2answers
49 views
how would i separate a string based on some pattern without loosing the match parameter in python?
this is the string i have (ignoring whitespace)
a = u'(%o3) (9*t*(7*t*(5*t*(3*t^2-1)/2-2*t)/3-3*(3*t^2-1)2)/4-4\r\n*(5*t*(3*t^2-1)2 \r\n-2*t)\r\n/3)\r\n /5\r\n(%i4) '
how would i split it into ...
4
votes
1answer
45 views
How to get a capture group that doesnt always exist?
I have a regex something like
(\d\d\d)(\d\d\d)(\.\d\d){0,1}
when it matches I can easily get first two groups, but how do I check if third occurred 0 or 1 times.
Also another minor question: ...
0
votes
2answers
43 views
Python regex for a text after an underscore, unless a specific word
Consider the following strings:
server
server_secure
server_APAC_secure
server_APAC
server_US
server_US_secure
server_EU_secure
server_ISRAEL
The template is straightforward:
The string server
An ...