Skip to main content

All Questions

0 votes
1 answer
50 views

I wrote a regex inside of a python script to analyse xml files but sadly its not working

I wrote a script to gather information out of an XML file. Inside, there are ENTITY's defined and I need a RegEx to get the value out of it. <!ENTITY ABC "123"> <!ENTITY ...
toki's user avatar
  • 11
2 votes
5 answers
234 views

Parsing text files with "magic" values

Background I have some large text files used in an automation script for audio tuning. Each line in the text file looks roughly like: A[BANANA] + B[PINEAPPLE] - C[CHERRY] [[BANANA]] BANANA # BANANA ...
user avatar
-1 votes
2 answers
4k views

How to use regex in python? [duplicate]

I must be missing something simple - whatever I do, I can't get my regex to match any strings: [~] $ python2.7 Python 2.7.12 (default, Aug 13 2016, 19:37:25) [GCC 4.2.1 Compatible Apple LLVM 7.3.0 (...
CaptainForge's user avatar
  • 1,395
3 votes
1 answer
284 views

Encode Python list in order to use re module

I have a text file in spanish, so it has thousands of words, some of them with accents. I'm using re module in order to extract some words, but when I got a list, some words are incomplete. This is ...
estebanpdl's user avatar
  • 1,233
-1 votes
1 answer
166 views

Use capture group in re.sub

I have the following code: >>> s = 'https://www.microsoft.com/ja-jp/store/tv/%E7%BE%8E%E7%94%B7-%E3%82%A4%E3%82%B1%E3%83%A1%E3%83%B3-%E3%82%B9%E3%82%BF%E3%83%BC%E8%AA%95%E7%94%9F-%E3%83%8E%...
David542's user avatar
  • 111k
2 votes
3 answers
97 views

What is the best way to use OR in python regex

I'm doing an homework on regex and having some difficulties with OR. Given the following strings: avc7fsrd5vcc12vfscsrwt1qw7eetrs&fsrsy should return t1 s fdjhads jhf&5672t3zcxvb,...
Anonymous's user avatar
1 vote
2 answers
91 views

Python regex finding sub-string

I'm New to python and regex. Here I'm trying to recover the text between two limits. The starting could be mov/add/rd/sub/and/etc.. and end limit is end of the line. /********** sample input text ...
Ashfaque Ahammed's user avatar
0 votes
3 answers
84 views

How to remove strings from in between brackets with regex...python [closed]

I need to pull out a single string containing the words from extracted fields: [[cat]][[dog]][[mouse]][[apple]][[banana]][[pear]][[plum]][[pool]] So from this I need: cat dog mouse apple banana pear ...
user avatar
2 votes
5 answers
2k views

How to split bracketed list in python with regex'?

I am trying to use the re module in python to split a string that represents a list. The list is identified by brackets. Input: "[1]first[2]second[3]third" ... etc Desired output: ['first', '...
Shruf's user avatar
  • 103
6 votes
4 answers
6k views

Delete rest of string after n-th occurence

I have the following string: a = "this.is.a.string" I wish to delete everything after the 3rd '.' symbol so that it returns trim(a) >>> "this.is.a" while a string without the 3rd '.' should ...
sachinruk's user avatar
  • 9,877
-1 votes
1 answer
61 views

Find string between 2 chars regex python

I'm trying to find URLs in html. This is the example I'm trying to match: href="http://(.+)"(?:.+) <a href="http://www.etf.rs/" target="_top"> This matches: www.etf.rs/" target= And it should:...
Dusan Milosevic's user avatar
0 votes
4 answers
68 views

Using a RegEx to find groups of numbers, replace with only the last member of the group

I have a csv file that's formatted like this (only relevant row shown): Global equity - 45%/45.1% Private Investments - 25%/21% Hedge Funds - 17.5%/18.1% Bonds & cash - 12.5%/15.3% I wrote a ...
n1c9's user avatar
  • 2,697
0 votes
1 answer
543 views

How to recognize string patterns?

I want to group strings in python, but I don't really know how to approach the problem. Lets say I have a list of file names: test-1.jpg test-2.jpg test-3.jpg supertest-828.jpg supertest-8429.jpg 5-...
JasonTS's user avatar
  • 2,597
-4 votes
4 answers
227 views

How to use "While()" in python [closed]

Hi all my code below allows me to extract some specific informations from the data and i would like that someone helps me to write this more properly by using a while so i can do this for many lines ...
James H's user avatar
  • 205