Skip to main content

All Questions

Tagged with
0 votes
2 answers
50 views

Replace a certain part of the string which matches a pattern in python 2.7 and save in the same file

I am trying to achieve something of this sort My input file has this kind of entries art.range.field = 100 art.net.cap = 200 art.net.ht = 1000 art.net.dep = 8000 I am trying to match the pattern like ...
Saswata Kar's user avatar
0 votes
0 answers
11 views

Parsing expression with python: from string to integers [duplicate]

I was trying to split this string in two numbers using multiple delimeters and re library in python Input: "['2 5']" Output [2,5] Code: data = re.split(r"'[ ]'",str(sys.stdin....
Sara's user avatar
  • 1
-1 votes
2 answers
91 views

find line containing exact number string not started with . or ending with any other digit [duplicate]

expression to find exact number in string that do not start with dot and not end with any other digit.(description) ticket=1740 text="SNMPD_TRAP_COLD_START:SNMP trap:(17405.737)cold start" ...
Zaman Azam's user avatar
5 votes
1 answer
8k views

Replace multiple characters using re.sub [duplicate]

s = "Bob hit a ball!, the hit BALL flew far after it was hit." I need to get rid of the following characters from s !?',;. How to achieve this with re.sub? re.sub(r"!|\?|'|,|;|."," ",s) #doesn't ...
Wkhan's user avatar
  • 105
0 votes
1 answer
87 views

String Manipulation to remove Change lines in a string

Given : I have a SQL Script with comments. Requirement : To parse the comments and sql queries separately and - Store Comments & also remove (--) [FACING PROBLEM IN THIS STEP] Run the respective ...
Golokesh Patra's user avatar
0 votes
2 answers
115 views

Extract string with date in Python

I have a list of strings in Python 2.7 like this: lst = [u'Name1_Cap23_o2_A_20160830_20170831_test.tif', u'Name0_Cap44_o6_B_20150907_20170707.tif', u'...
kurdtc's user avatar
  • 1,631
0 votes
1 answer
138 views

how to split huge html to little files

I'm trying to take a massive html file and split it to sections. The file is generated by Jenkins and looks like this: [XXX] text1 [XXX] text2 [YYY] text4 [XXX] text3 [YYY] text5 [ZZZ] text6 ... I ...
CIsForCookies's user avatar
0 votes
2 answers
49 views

Regex: How to get everything within brackets before a certain character?

How would I return a string within brackets after a certain character? I am interested in the string before |#| within the brackets (). Given two strings: s1 = 'This is the part of the string not of ...
mizzlosis's user avatar
  • 587
0 votes
1 answer
700 views

extracting multiple words from a string using regex

I am trying to extract all the references from part of a paper as a list. For now I've just got a paragraph and set it as a string. I was wondering if it is possible to do this using regex on python? ...
qwerty's user avatar
  • 115
-2 votes
2 answers
260 views

How can I get a piece of a string between two specific characters from a string in Python

I have a Json file which I converted to a dictionary in python. One of the values called (target) in the dictionary has this string. I want to create a file with this string name (...
Mona's user avatar
  • 311
7 votes
1 answer
18k views

Remove '\n' in text in pandas python

The following code is current code that i use to remove \n in ['text'] column: df = pd.read_csv('file1.csv') df['text'].replace('\s+', ' ', regex=True, inplace=True) # remove extra whitespace df['...
Lily's user avatar
  • 135
0 votes
1 answer
27 views

separate similar type of substrings from a string

I have a string that resembles an XML format. the above string contains several substrings starting with <SingleProvisioningRequest> and ending with </SingleProvisioningRequest>. is ...
Mehtab Anjum's user avatar
0 votes
1 answer
49 views

Python regex match grouping

RANDOMSTRING are alphanumeric including spaces at most 50 characters RANDOMSTRING $RANDOMFLOAT Paid with Visa ending in RANDOMINT *- For: RANDOMSTRING -* RANDOMINTx *RANDOMSTRING* (RANDOMSTRING) =E2=...
leo's user avatar
  • 25
-1 votes
1 answer
107 views

How to find the highest value of a sub-string ending in integer in Python?

How to find the highest value of a sub-string ending in integer in Python? Input: a = """ classification-filters { filter123 { filter025 { filter0 { """ Output: sub-string ending ...
Saumitra Prabhudesai's user avatar
1 vote
1 answer
46 views

Reg ex partial fail

Bear with me on this as I might not be explaining this too well. I have a simple regex: ^(The\s)?(cat\s)?(sat\s)?(on\s)?(the\s)?(mat\.)? To which the text The cat sat on the mat. passes ...
Ghoul Fool's user avatar
  • 6,987

15 30 50 per page
1
2 3 4 5
9