1
vote
2answers
18 views

python simple router url matcher, how to re match with first “/” occurrence

I have a router module, what compares a subject with a regex, and link the occurrences with a coincident key mask. (its a simple url routing filtering like symfony ...
2
votes
2answers
34 views

Split diary file into multiple files using Python

I keep a diary file of tech notes. Each entry is timestamped like so: # Monday 02012-05-07 at 01:45:20 PM This is a sample note Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do ...
0
votes
3answers
23 views

search patterns with variable gaps in python

I am looking for patterns in a list containing different strings as: names = ['TAATGH', 'GHHKLL', 'TGTHA', 'ATGTTKKKK', 'KLPPNF'] I would like to select the string that has the pattern 'T--T' (no ...
1
vote
2answers
48 views

python match regular expression

i need to compare a subject with a regex, and link the occurrences with a coincident key mask key_mask = 'foo/{one}/bar/{two}/hello/{world}' regex_mask = 'foo/(.*)/bar/(.*)/hello/(.*)' subject = ...
0
votes
2answers
37 views

How to combine several regex search patterns into on pattern (i.e., use an addition operator) in python

I'm trying to combine input from a user as part of a regex search. Since I only want the user-provided pattern to be searched in particular lines, I want to combine (i.e., concatenate) the pattern ...
0
votes
1answer
28 views

Python regex. Report start,end of string blocks

I'am struggling with python regex to get the correct output. I have file with strings like this: 80H236M7I106M2885H beside integers string can contain: IDMSH I am trying to workout start end of ...
0
votes
3answers
51 views

Not able to inline replace using re.sub and io.StringIO in Python

I have written this method in order to replace text in line. It prints the correct text as I want it to be replaced but it is not updating those changes in the file. I am quite new to Python, Could ...
0
votes
0answers
57 views

Most efficient way to check strings for illegal characters

Where the illegal character set is in many different ranges and individual points, what would be the most efficient way to check strings against such illegal set. I timed two methods, and one is ...
4
votes
2answers
47 views

Hyphen in verbose regex comment causes error

What's wrong with the following code - I pinpointed it to the hyphen in the comment, but why should that cause an error? import re valid = re.compile(r'''[^ \uFFFE\uFFFF # non-characters ]''', ...
0
votes
1answer
52 views

python match variable text using regular expression

I am new to python and trying to find out how way to match a sentence with variable words for examples 'The file test.bed in successfully uploaded' Now here in the above sentence, the file name ...
1
vote
2answers
35 views

Find n words starting with capital letter before 2 words of capital letters (regex)

I have written this regex but this is not working as expected. ((?:[A-Z][\w]+)?),[\s]([A-Z]{2}) Following are sample inputs. Fort Worth, TX This is Forth Worth, TX We are looking for someone from ...
3
votes
5answers
101 views

Replace an underscore separated substring in the middle of a comma separated string

I have a file with multiple lines in it like this: 'AMS_Investigation|txtt.co_BigtittedBlondOtherNight_1371078139195_+14155186442', {'cf:rv': '0'} I want to replace the 1371078139195 (in this ...
0
votes
3answers
36 views

how to extract part of string in RegEx

I have a string: The estimated delivery time will be approximately 5 - 7 business days from the time of order. I want to extract: 5-7 business days from this string. I wrote regex: ...
-1
votes
3answers
40 views

python regex extraction of fields using re.compile

array= ['gmond 10-22:13:29','bash 12-25:13:59'] regex = re.compile(r"((\d+)\-)?((\d+):)?(\d+):(\d+)$") for key in array : res = regex.match(key) if res: print res.group(2) ...
0
votes
5answers
51 views

RegEx For Multiple Search & Replace

I'm trying to do a search and replace (for multiple chars) in the following string: VAR=%2FlkdMu9zkpE8w7UKDOtkkHhJlYZ6CaEaxqmsA%2B7G3e8%3D& One or more of these characters: %3D, %2F, %2B, %23, ...

15 30 50 per page