1
vote
3answers
19 views

Finding certain pattern in string, why the other matches?

I want to isolate numbers in a string. These will come directly before and after a / I have done this which is adequate: a = "test0/0" print re.split("(\d)/(\d)", a) This has the required numbers ...
1
vote
4answers
39 views

Regular expression to match an empty string?

I want to match and group any of these listed words: aboutus/,race/,cruise/,westerlies/,weather/,reach/,gear/ or empty_string Here is a solution, but which will not match the empty_string: ...
0
votes
0answers
13 views

java.net.MalformedURLException:Fetching data from links embedded in a website using apache nutch

Hi guys I am using apache nutch to extract data. I am able to extract data from a website like so: :-http://www.truelocal.com.au/ but can we fetch data for specific links from the websites? :- ...
0
votes
1answer
12 views

Overriding URLField's validation with custom validation

How can I override django's URLField's validation with a custom validation? And where should this be done? I want it to accept urls without a domain ending too.
0
votes
1answer
17 views

MongoDB: Transform PHP code to Python code

I was searching a way to combine $in and $regex in mongoDB and found exactly the same question with exactly what I want to do. The problem is that the answer is in PHP and I don't have an idea about ...
0
votes
1answer
33 views

Python Regular Expressions Re.Search

I am having issues figuring out what this regular expression means: import re if re.search('^(0*)$','010'): print 'match' else: print 'no match' I'm mainly confused about the 0* in the ...
0
votes
3answers
28 views

Regex extract text inside '**' characters

I need a regex to extract a word from among a plethora of ** characters. I know this is trivial for regex gurus... I'm just having some difficulty with it. phrase = re.search('\*.*(\w.*)\*', ...
0
votes
0answers
21 views

Matching regex to list items in Python

I am attempting to write a python script that shows the URL flow on my installation of nginx. So I currently have my script opening my 'rewrites' file that contains a list of of regex's and locations ...
0
votes
1answer
37 views

Verify if string is valid regex?

EDIT: I cannot use python's 're' This is for an assignment so I don't want the answer in code, rather just some tips in the right direction. I am trying to code a function that returns True if ...
2
votes
1answer
32 views

How to get multiple regex matches in python?

I have this text: <div class="additional-details"> <div class="mark-container"> <input type="checkbox" id="comp-80174649" value="80174649" data-heading-code="2550"/> ...
1
vote
4answers
42 views

Mapping Boolean formulas to Python set expressions

Say I have a Boolean formula that uses a known set of tokens, e.g.: Boolean operators: and, or, not Grouping operators: (, ) Given a Boolean formula using those tokens, e.g.: F: (A or B) and ...
1
vote
3answers
35 views

Group regex in python

I was trying a simple regex search to check for validity of an IPv6 address. I first tried a simple example for searching simple hex characters in a 4 block system. For eg: The string - ...
1
vote
4answers
64 views

List of compiled regexes in Python

I have a lot of substitution patterns which I need for text cleaning. I load the data from a database and compile the regular expressions before for performance reasons. Unfortunately with my approach ...
0
votes
4answers
43 views

Check that a string starts with a drive letter in Python

I'm writing a script that will take a list of file paths as input. I want the script to make sure the strings in the input file are, or at least appear to be, valid full Windows paths, that include ...
0
votes
2answers
45 views

Python regex exact pattern

I am a beginner in regex using Python, what I am trying to do is including a ppattern that has to be found exactly as it is when searching for a regex. For example \w[$X|@] so if $X is not found ...
1
vote
1answer
35 views

Modifying a Regex Expression

i have several strings to match certain expressions where i want to match and extract 2 words after the prepositions along with the preps themselves.. And they do a good job too . But i need to modify ...
0
votes
0answers
16 views

Matching Multiple 'id' Values Using RegEx in Combination with HTML::TreeBuilder

The id values for particular span elements on multiple pages in my database have a regexable pattern. The id is something like item_10Title_For_Project(SOMETHING HERE)Title_For_Project I'd like to ...
1
vote
1answer
25 views

Regular expression match in python

I'm trying to extract a certain part of the text from a file. I'm having trouble making the regular expression match the least number of characters as possible. Here is an example text file. ...
0
votes
2answers
25 views

In python using Regex, how do I insert a string after a string with a close-parenthesis character?

I have lines of data like this: (ABCD:0.00825830327156463345,(LKSDJF:0.00000254996576400768,SDFADS:0.00917039554517301569):0.16367666117488463562,OIUO:0.00401845774067355072):0.0; ...
0
votes
1answer
22 views

Python 2.7 regex with format multiple list items

Imagine I want to find all time expressions referring to 'AM' and 'PM' in a string. Let's ignore for the moment that I could use '[AP]M' to do this (because I'm actually pulling the list of valid ...
1
vote
2answers
33 views

regular expression to get string from text()

I have this html: <p class="marB0">Phone:+97143396222<br> Email:[email protected]</p> And I want to get the phone number I get the text like this: ...
3
votes
2answers
34 views

How to replace single qoute to backslash+single qoute in Python

Need to replace ' to \' But that what I get: >>> s = "It's nice to have an example" >>> s.replace("'", "\\'") "It\\'s nice to have an example" >>> s.replace("'", "\'") ...
0
votes
2answers
30 views

How can I check for specific strings in python?

I'm used to doing Regex's in a variety of languages, but I don't know Python well. I'm looking for a regex that will do the same as the following JavaScript regex: (disc|dis|se|oti)(\d+)\W i.e. ...
0
votes
3answers
45 views

Python regex to remove all occurances of [Number]

I'm looking for the regex statement in python that will remove all occurances of [1] or [17] or basically [*] from a string. The occurances are as follows where * equals some number: [*] [ * ] [ *] ...
0
votes
3answers
22 views

regex + Python: How to find string with '?' in it?

I have a multi-line string in content variable, and I need to retreive all matches for a pattern uri containing question mark in it. This is what I have so far: content = """ /blog:text:Lorem ipsum ...
1
vote
0answers
44 views

All possible values that will match a regular expression [migrated]

This is a similar question to Reversing a regular expression in python, but I am looking for the set of all possible values that will match a regular expression pattern. To avoid an infinite set of ...
-1
votes
1answer
24 views

How to use recursion in python to parse method body from java code?

I have a java code and i need to parse it in python.I am using regex in python for this purpose. I was successfully able to find method names , but to find method body i need to write regular ...
3
votes
1answer
47 views

output expanded ip list from text in python

I have text that contains IP and subnet data. I need to output each IP within a given range. The input looks like this: 10.14.21.23 0.0.0.0 20.54.0.0 0.0.127.255 30.76.21.0 0.0.0.255 ...
0
votes
2answers
25 views

python regex for current time

I am having some trouble with regex it seems in creating a regex that matches time in the format "hh/mm/ss". I am making an alarm clock in python. here's what I currently have: import time, re ...
0
votes
2answers
24 views

How to use regex to parse a S3 bucket list of files - Python

I have the following method: def scan_s3dir(dirname): try: cmd = "s3cmd ls {s3bucket} --recursive".format(s3bucket=dirname) output = subprocess.check_output([cmd], ...
1
vote
2answers
17 views

Python - Regex - findall duplicates

I'm trying to match e-mails in html text using the following code in python my_second_pat = '((\w+)( *?))(@|[aA][tT]|\([aA][tT]\))(((( *?)(\w+)( ...
0
votes
1answer
33 views

Assistance with regex python

I need help with a regex pattern that allows me to do the below but I'm not quite sure how to. command, extra = re.search(SomeRegexPattern, string).groups() # or split it to be a list Input: ...
1
vote
1answer
26 views

Filtering a dataframe based on a regex

Say I have a dataframe my_df with a column 'brand', I would like to drop any rows where brand is either toyota or bmw. I thought the following would do it: my_regex = ...
0
votes
1answer
31 views

Scrapy: Modify rules for scraping web page

I've started to use scrapy for a project of mine to scrape data off a tennis website. Here is an example page that I want to scrape data off. As you can see, I want to scrape data for a tennis player. ...
1
vote
1answer
40 views

Comparing regexes with recursion

So I'm stuck here trying to recursively compare regexes with recursion. The user will create an object with two parameters, each a string of length one. These strings can only be "0", "1" or "2". But ...
0
votes
1answer
17 views

Python parse url in string

I'd like to get urls in strings. For example I got: "You got to see this link[http://some.link/you/have?to=see]" I think theses are non-valid url characters: "'()[]{}
2
votes
2answers
49 views

How can I match multiple elements enclosed in corner brackets with python regex?

I have some strings that look like this: <a href="javascript:updateParent('higashino/index.html')">東野 圭吾「夢幻花」「白夜行」</a>他<br> Now I want to extract the link and the strings inside ...
0
votes
2answers
56 views

regex is counting only one pattern, when two same patterns are kept consecutive.why?

The following is an input. INPUT 2 businessman video demeanor demeanor dishonest acknowledge dvd honor sister opportunity keen labour artistic favourite red definition impatient take ...
0
votes
2answers
32 views

python: match and group sets of similar strings in a loop

I am trying to match and group similar strings from a list but I'm not sure how to approach this. I have the following list: tablenames =[ 'SCS_q104', ...
1
vote
1answer
26 views

find a keyword in a string with python and regex

I would like to find a keyword in a string that can be at the begining, the end, or anywhere in the string. I started with something like that: import re my_keyword = "in ocean" regex = ...
2
votes
2answers
27 views

Substitution of ACD|BCD like regular expression in python

A, B, C and D represent different parts of a regular expression. The effect I want to achieve: The input string is ACD or BCD. After substituting C with E, the output should be AED or BED. The ...
0
votes
1answer
30 views

python get float numbers in reqular expression

I have the possibilities of these formats: 1,34$ 1.34$ 114$ 0,34$ 0.34$ and i want to get just the number . i used this regular express (\d+),(\d*) but when i test it in 1,34$ i got two ...
1
vote
0answers
46 views

How to validate, store and execute user rules?

In my application: there are users. emails come in to the system. users can use a web browser to define filter rules for their inbound emails. Filter rules are of the general form "if field ...
1
vote
1answer
22 views

Regex to return 2 groups

I have the following data that I need to extract 2 groups from. I need the 3 letter code in caps between var and Destinations, and in the second group, I need all the 3 letter codes (without single ...
1
vote
0answers
27 views

creating a regular expression for parsing IUPAC organic compound names

I am trying to create a parser in my free time that could parse out all the functional groups from the name of a organic compound. Side by side, i am also trying to make a display program which can ...
0
votes
3answers
36 views

Conditioning on Regex,Python

i have several strings from which i need to extract the block numbers. The block numbers are of the format type "3rd block" , "pine block" ,"block 2" and "block no 4". Please note that is just the ...
0
votes
2answers
31 views

Use Regex to get text after /

I have this text from a website <a class='link--wrapper' href='/china/sights/architecture/old-buildings'> <a class='link--wrapper' ...
1
vote
1answer
26 views

Is this an efficient way of listing all .mp3 files inside in a directory (including eventual subdirectories) in Python?

Is this a good approach? Is there a more efficient way to do it (without having to trade code readability for efficiency) ? for root, dirs, files in os.walk(path, topdown=False): for name in ...
0
votes
3answers
41 views

Regex to find words between two tags

How can I use regex in python to find words between tags? s = """<person>John</person>went to<location>London</location>""" ...... ....... print 'person of name:' John print ...
0
votes
2answers
25 views

Regex: match fullstop and one word in python

I am new to regex. I wish to write a regex which matches a '.' followed by a whitespace followed by a word(which does not contain whitespace. For example, in the string "The sound of cracking. ...

15 30 50 per page