I've been wondering about how hard it would be to write some Python code to search a string for the index of a substring of the form ${expr}, for example, where ... |
I have the following problem:
# line is a line from a file that contains ["baa","beee","0"]
line = TcsLine.split(",")
NumPFCs = eval(line[2])
if NumPFCs==0:
...
|
I have a text file that looks a bit like:
random text random text, can be anything blabla %A blabla
random text random text, can be anything blabla %D blabla
random text random text, ...
|
I have a multi-line string like this:
"...Togo...Togo...Togo...ACTIVE..."
I want to get everything between the third 'Togo' and 'ACTIVE' and the remainder of the string. I am unable to create a regular expression ... |
stringExp = "2^4"
intVal = int(stringExp) # Expected value: 16
This returns the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal ...
|
Is there a quick way in Python to replace strings by starting from the end? For example:
>>> def rreplace(old, new, occurence)
>>> ... # Code to replace the ...
|
I'm using python, and I want a function that takes a string containing a mathematical expression of one variable (x) and returns a function that evaluates that expression using lambdas. Syntax ... |
|
I need to either call exec() or eval() based on an input string "s"
If "s" was an expression, after calling eval() I want to print the result if the result was ... |
I am newbie to python,i am facing below issue please help me:
I read line by line from one file, each line having field name and its value,
now i have to ... |
Need to exclude blocks that are located with a regular expression when preceded with # and any number of spaces. Here is a example file
&START A=23 ... more ...
|
Imagine something like
exp(49/200)+(x-49/200)
I want to pass as argument of the function "roundn" whatever operation that is not a addtion or a subtraction
So my expresion became
roundn(exp(roundn(49/200,n)),n)+(x - roundn(49/200,n)
Well the expression I want ... |
For example, I have a list a = ['3*4', '2*3', '4*6'],
I want to print the string in the list whose result will be the largest, '4*6' in this case.
|
In my code, I load up an entire folder into a list and then try to get rid of every file in the list except the .mp3 files.
import os
import re
path = ...
|
From the following question
How to automatically remove certain preprocessors directives and comments from a C header-file?
header = "" #some string
p_macro = re.compile("#if.*?#endif", re.MULTILINE + re.DOTALL)
p_comment = re.compile("/\*.*?\*/", re.MULTILINE ...
|
PyRun_String("if True: 1\nelse: 0", Py_eval_input, globals, globals);
returns error with PyErr_Print() printing out:
File "<string>", line 1
if True: 1
^
What am I doing wrong?
Thank you.
|
I feel there must be a simpler/cleaner/faster (choose one or more) way to write this expression...
take a BigString = "This is a long sentence about a red cat named dude."
and LittleStringList ... |
I apologize in advance for the newbie question. I'm trying to figure out a way to find all of the occurrences of a regular expression in a string including the overlapping ones. For example, given the string 123456789 I'd like to use the RE ((2)|(4))[0-9]{3} to get the following matches: 2345 4567 Here's what I'm trying so far: #!/usr/bin/env python ... |
String searching using a for loop and regular expressions by fireball73 Tue Mar 01, 2011 11:12 am Hello everyone, I am an astronomy student and I've been learning Python for a laboratory project involving the automation of a telescope. Part of which involves constructing an algorithim to search a database of astronomical objects. I have tried to do this two ... |
Hi All, I am trying to extract a string using regular expression like this import re string = "[this is my string and can have anything here,even -] some/other/string" I want to get the value withing the square brackets which is part of the string itself result needed "this is my string and can have anything here,even -" This is how ... |
Hello all, i am sure this is really simple but i am scratching my head trying to find out a way. I discover that using regular expressions is making my life easier because i am dealing with text manipulation. Let's suppose i have this line: " weight losses | weight loss | Weight loss | Weight Loss " 168.578313 "weight loss" ... |
According to the python docs there's something called the "Unicode character properties database", which tags unicode characters with information such as whether the character is considered alphanumeric. Either that database doesn't consider a 'LATIN SMALL LETTER A WITH ACUTE' to be alphanumeric, or python doesn't implement those tags correctly. Maybe the concept of alphanumeric isn't used in the unicode world? So...you ... |
Thank you all for your help. I'll try to explain what I would like to do. I would like to accomplish search using pattern compiled from GA[CG]{1}GA[CG]{1} and others elements of list which are pretty similar(using loop) to search into the same list. I decide to try make the list for searching as list of strings, and then searching is there ... |