Re: Suggestion: Regex string specifier like r and f

2023-01-08 Thread Barry
> On 8 Jan 2023, at 21:16, Raphael Santiago > wrote: > > Maybe something like re"" > It should behave exactly like a raw string but would be useful for syntax > highlighting and debugging. Perhaps also for type hinting expected regex > input (don't

Re: Suggestion: Regex string specifier like r and f

2023-01-08 Thread Cameron Simpson
On 08Jan2023 12:44, Raphael Santiago wrote: Maybe something like re"" It should behave exactly like a raw string but would be useful for syntax highlighting and debugging. Perhaps also for type hinting expected regex input (don't know if this is feasible). A nice idea. (Though

Suggestion: Regex string specifier like r and f

2023-01-08 Thread Raphael Santiago
Maybe something like re"" It should behave exactly like a raw string but would be useful for syntax highlighting and debugging. Perhaps also for type hinting expected regex input (don't know if this is feasible). -- https://mail.python.org/mailman/listinfo/python-list

Re: Definitive guide for Regex

2021-10-05 Thread Karsten Hilbert
Am Thu, Sep 30, 2021 at 12:29:16PM +0100 schrieb Shaozhong SHI: > I am trying to look for a definitive guide for Regex in Python. > Can anyone help? If you tell us what you tried in order to look we can perhaps guide you on how to take a better look. Spoonfeeding doesn't seem to be a

Re: Definitive guide for Regex

2021-10-02 Thread Barry Scott
> On 1 Oct 2021, at 10:58, Shaozhong SHI wrote: > > Hi, Barry, > > In cases of automating checking, validation and producing reports in the > context of data quality control and giving specific feedback to production > teams, regex is perhaps the only way. > >

Re: Definitive guide for Regex

2021-10-01 Thread Jach Feng
Shaozhong SHI 在 2021年9月30日 星期四下午7:29:47 [UTC+8] 的信中寫道: > Dear All, > > I am trying to look for a definitive guide for Regex in Python. > Can anyone help? > > Regards, > > David Try the rexegg.com which is a site dedicate to this subject and has many reso

Re: Definitive guide for Regex

2021-10-01 Thread Shaozhong SHI
Hi, Barry, In cases of automating checking, validation and producing reports in the context of data quality control and giving specific feedback to production teams, regex is perhaps the only way. Perhaps, we can give each element of data specifications a name, that are associated with a regex

Re: Definitive guide for Regex

2021-09-30 Thread Barry Scott
> On 30 Sep 2021, at 19:35, dn via Python-list wrote: > > On 01/10/2021 06.16, Barry Scott wrote: >> >> >>> On 30 Sep 2021, at 12:29, Shaozhong SHI wrote: >>> >>> Dear All, >>> >>> I am trying to look for a definitive gu

Re: Definitive guide for Regex

2021-09-30 Thread dn via Python-list
On 01/10/2021 06.16, Barry Scott wrote: > > >> On 30 Sep 2021, at 12:29, Shaozhong SHI wrote: >> >> Dear All, >> >> I am trying to look for a definitive guide for Regex in Python. >> Can anyone help? > > Have you read the python docs for the r

Re: Definitive guide for Regex

2021-09-30 Thread Barry Scott
> On 30 Sep 2021, at 12:29, Shaozhong SHI wrote: > > Dear All, > > I am trying to look for a definitive guide for Regex in Python. > Can anyone help? Have you read the python docs for the re module? Barry > > Regards, > > David > -- > https://mai

Definitive guide for Regex

2021-09-30 Thread Shaozhong SHI
Dear All, I am trying to look for a definitive guide for Regex in Python. Can anyone help? Regards, David -- https://mail.python.org/mailman/listinfo/python-list

Re: using regex for password validation

2020-12-23 Thread Chris Angelico
On Thu, Dec 24, 2020 at 12:56 PM dn via Python-list wrote: > > On 24/12/2020 12:25, Chris Angelico wrote: > > On Thu, Dec 24, 2020 at 9:42 AM dn via Python-list > > wrote: > >> Hang-on though, look at how much 'work' is involved, compared with a > >&g

Re: using regex for password validation

2020-12-23 Thread dn via Python-list
On 24/12/2020 12:25, Chris Angelico wrote: On Thu, Dec 24, 2020 at 9:42 AM dn via Python-list wrote: Hang-on though, look at how much 'work' is involved, compared with a single line of RegEx! Why go to such bother? There's several reasons. Good question! Look at this al

Re: using regex for password validation

2020-12-23 Thread dn via Python-list
On 24/12/2020 12:20, 2qdxy4rzwzuui...@potatochowder.com wrote: On 2020-12-24 at 11:41:15 +1300, dn via Python-list wrote: On 24/12/2020 06:03, Sadaka Technology wrote: hello guys, I have this pattern for password validation (regex): [...] Is it my imagination, or does a password in

Re: using regex for password validation

2020-12-23 Thread Chris Angelico
On Thu, Dec 24, 2020 at 10:21 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > If you're going to wander out of ASCII, then don't forget to address > Unicode confusables. Nothing is more embarrassing than scribbling your > complicated password on a sticky note and then not being able to tell > the

Re: using regex for password validation

2020-12-23 Thread Chris Angelico
On Thu, Dec 24, 2020 at 9:42 AM dn via Python-list wrote: > Hang-on though, look at how much 'work' is involved, compared with a > single line of RegEx! Why go to such bother? There's several reasons. Good question! Look at this alternative: def validate_password(att

Re: using regex for password validation

2020-12-23 Thread 2QdxY4RzWzUUiLuE
On 2020-12-24 at 11:41:15 +1300, dn via Python-list wrote: > On 24/12/2020 06:03, Sadaka Technology wrote: > > hello guys, > > > > I have this pattern for password validation (regex): [...] > > passwordpattern = > > "^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[@

Re: using regex for password validation

2020-12-23 Thread dn via Python-list
On 24/12/2020 06:03, Sadaka Technology wrote: hello guys, I have this pattern for password validation (regex): I want these rules to be applied: Minimum 8 characters. The alphabets must be between [a-z] At least one alphabet should be of Upper Case [A-Z] At least 1 number or digit between [0

Re: using regex for password validation

2020-12-23 Thread Chris Angelico
On Thu, Dec 24, 2020 at 4:09 AM Sadaka Technology wrote: > > hello guys, > > I have this pattern for password validation (regex): > > I want these rules to be applied: > > Minimum 8 characters. > The alphabets must be between [a-z] > At least one alphabet should be

Re: using regex for password validation

2020-12-23 Thread Grant Edwards
Python issue!) You're far, far better off writing a function that tests each rule separately, so that you can tell the user _why_ the password isn't allowed. If you use a regex, it's just pass/fail. The user won't have any idea how to fix the problem. -- Grant Edwards

Re: using regex for password validation

2020-12-23 Thread MRAB
On 2020-12-23 17:03, Sadaka Technology wrote: hello guys, I have this pattern for password validation (regex): I want these rules to be applied: Minimum 8 characters. The alphabets must be between [a-z] At least one alphabet should be of Upper Case [A-Z] At least 1 number or digit between [0

Re: using regex for password validation

2020-12-23 Thread Mats Wichmann
On 12/23/20 10:03 AM, Sadaka Technology wrote: hello guys, I have this pattern for password validation (regex): I want these rules to be applied: Minimum 8 characters. The alphabets must be between [a-z] At least one alphabet should be of Upper Case [A-Z] At least 1 number or digit between [0

using regex for password validation

2020-12-23 Thread Sadaka Technology
hello guys, I have this pattern for password validation (regex): I want these rules to be applied: Minimum 8 characters. The alphabets must be between [a-z] At least one alphabet should be of Upper Case [A-Z] At least 1 number or digit between [0-9]. At least 1 character from [ _ or @ or

Re: Regarding Regex timeout behavior to minimize CPU consumption

2020-12-06 Thread Dan Stromberg
t compiling, but matching - most likely backtracking > > from lots of promising but ultimately unsuccessful partial matches. > > > >> regex = r'data-stid="section-room-list"[\s\S]*?>\s*([\s\S]*?)\s*' \ > >> > >> > > r'(?:cla

Re: Regarding Regex timeout behavior to minimize CPU consumption

2020-12-06 Thread Barry
helps the OP much. Compiled > regular expressions are cached, but more importantly, if a match takes > long enough that specifying a timeout is useful, the time is almost > certainly not spent compiling, but matching - most likely backtracking > from lots of promising but ultimately unsucc

Re: Regarding Regex timeout behavior to minimize CPU consumption

2020-12-05 Thread Peter J. Holzer
match takes long enough that specifying a timeout is useful, the time is almost certainly not spent compiling, but matching - most likely backtracking from lots of promising but ultimately unsuccessful partial matches. > regex = r'data-stid="section-room-list"

Re: Regarding Regex timeout behavior to minimize CPU consumption

2020-12-05 Thread sjeik_appie
Hi, Timeout: no idea. But check out re.compile and re.iterfind as they might speed things up. I often compile a regex once upon import, then use it in functions On 27 Nov 2020 13:33, Shahique Khan wrote: Hi Team, I have noticed if our regex sometimes does not give a

Regarding Regex timeout behavior to minimize CPU consumption

2020-11-27 Thread Shahique Khan
Hi Team, I have noticed if our regex sometimes does not give a result and on that time regex took more time in returning response (empty response). My Question is can we set a timeout parameter (in seconds/millisecond) with re.find or anywhere in code to avoid CPU consumption if regex takes more

Re: Regex Group case change

2020-10-01 Thread Cameron Simpson
It is good to see a nice small piece of code which we can run. Thank you. So there are a number of things to comment about in the code below; comments inline under the relevant piece of code (we prefer the "inline reply" style here, it reads like a conversation): On 01Oct2020 15:15, Raju wrot

Re: Regex Group case change

2020-10-01 Thread Raju
title()group(3) else: output.title() On Thursday, October 1, 2020 at 10:53:16 PM UTC+1, cameron...@gmail.com wrote: > On 01Oct2020 12:41, Raju wrote: > >I want to change the case on input string i was able to match using > >python regex but couldn't find the

Re: Regex Group case change

2020-10-01 Thread Cameron Simpson
On 01Oct2020 12:41, Raju wrote: >I want to change the case on input string i was able to match using >python regex but couldn't find the way to change the case. > >For example string: >Input: 7Section Hello Jim >output: 7Section hello Jim > >I was doing if statment w

Regex Group case change

2020-10-01 Thread Raju
Hello Everyone, I want to change the case on input string i was able to match using python regex but couldn't find the way to change the case. For example string: Input: 7Section Hello Jim output: 7Section hello Jim I was doing if statment with regex if re.match("(\d+\w* )(

Re: Regex to change multiple lines

2020-09-04 Thread Termoregolato
Il 03/09/20 22:16, Chris Angelico ha scritto: Hmm. Have you considered using CSS to do this? Markdown is generally fairly easy to style with CSS. Yes, infact these are files where I'll insert a tag (in the example , to show the errors find at a second revision due they are of another kind, b

Re: Regex to change multiple lines

2020-09-03 Thread Chris Angelico
On Fri, Sep 4, 2020 at 5:36 AM Termoregolato wrote: > > Il 03/09/20 16:10, Termoregolato wrote: > > > I need to change every occurrence of a sequence between two chars > > Thanks to all for your replies, it's time to learn regular expressions, > but now I've some valid pointers from you. > > The w

Re: Regex to change multiple lines

2020-09-03 Thread Termoregolato
Il 03/09/20 16:10, Termoregolato wrote: I need to change every occurrence of a sequence between two chars Thanks to all for your replies, it's time to learn regular expressions, but now I've some valid pointers from you. The work I must do here, to explain, is to get some markdown files, an

Re: Regex to change multiple lines

2020-09-03 Thread Tim Chase
Derp, sorry about the noise. I mistook this message for a similar dialog over on the Vim mailing list. For Python, you want re.sub(r"%%(.*?)%%", r"\1", s, flags=re.S) or put the flag inline re.sub(r"(?s)%%(.*?)%%", r"\1", s) -tim On 2020-09-03 09:27, Tim Chase wrote: > On 2020-09-03 16:1

Re: Regex to change multiple lines

2020-09-03 Thread Tim Chase
On 2020-09-03 16:10, Termoregolato wrote: > -- original > This is the %%text that i must modify%%, on a line, %%but also > on the others%% that are following > > I need to change to > > -- desidered > This is the text that i must modify, on a line, but > also on the others that are following Sho

Re: Regex to change multiple lines

2020-09-03 Thread Chris Angelico
group, but I presume that that's intentional. To solve this, you can make the asterisk "non-greedy" by adding a question mark after it: rebarredtext = r'~~([^>]*?)~~' Now it matches as *little* as it possibly can. Additionally, you can get the regex engine to

Regex to change multiple lines

2020-09-03 Thread Termoregolato
t;, "" + line + "") but it changes only the biggest occurrence: how can I do to change all occurrences? I'm really a regex newbie, TIA -- test This is the text that i must modify%%, on a line, %%but also on the others that are following -- https://mail.python.org/mailman/listinfo/python-list

Re: a regex question

2019-10-25 Thread dieter
Maggie Q Roth writes: > There are two primary types of lines in the log: > > 60.191.38.xx/ > 42.120.161.xx /archives/1005 > > I know how to write regex to match each line, but don't get the good result > with one regex to match both lines. > > Can

Re: a regex question

2019-10-25 Thread Antoon Pardon
On 25/10/19 12:22, Maggie Q Roth wrote: > Hello > > There are two primary types of lines in the log: > > 60.191.38.xx/ > 42.120.161.xx /archives/1005 > > I know how to write regex to match each line, but don't get the good result > with one regex

Re: a regex question

2019-10-25 Thread Brian Oney via Python-list
On October 25, 2019 12:22:44 PM GMT+02:00, Maggie Q Roth wrote: >Hello > >There are two primary types of lines in the log: > >60.191.38.xx/ >42.120.161.xx /archives/1005 > >I know how to write regex to match each line, but don't get the good >resu

a regex question

2019-10-25 Thread Maggie Q Roth
Hello There are two primary types of lines in the log: 60.191.38.xx/ 42.120.161.xx /archives/1005 I know how to write regex to match each line, but don't get the good result with one regex to match both lines. Can you help? Thanks, Maggie -- https://mail.python.org/ma

Re: How to use regex to search string between {}?

2019-08-28 Thread Sayth Renshaw
> > A site like http://www.pyregex.com/ allows you to check your regex with > slightly fewer clicks and keystrokes than editing your program. Thanks Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use regex to search string between {}?

2019-08-28 Thread Jason Friedman
> > If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} > > import re > r = re.search('{.}', path) > # r should be ['h1,h2,h3,h4'] but I fail > > Why always search nothing? > A site like http://www.pyregex.com/ allows you to check your regex with sl

Re: How to use regex to search string between {}?

2019-08-23 Thread Chris Angelico
On Fri, Aug 23, 2019 at 6:44 PM lampahome wrote: > > I want to parse a path string with multiple files and try to figure out a > one-line way. > > If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} > > What I thought is use regex.search, but the pattern always failed. > > I use below: > import re

How to use regex to search string between {}?

2019-08-23 Thread lampahome
I want to parse a path string with multiple files and try to figure out a one-line way. If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} What I thought is use regex.search, but the pattern always failed. I use below: import re path = /home/admin/hello/yo/{h1,h2,h3,h4} r = re.search('{.}', path

Re: regex string matching python3

2018-10-01 Thread Brian J. Oney via Python-list
On Mon, 2018-10-01 at 10:49 -0700, nanman3...@gmail.com wrote: > I have a string like this:  >  > b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' >  > And I would like to  extract the numbers corresponding to S,D,F and M in this > string and convert them into an array like this:  >  > [ '89.9'

Re: regex string matching python3

2018-10-01 Thread MRAB
On 2018-10-01 18:49, nanman3...@gmail.com wrote: I have a string like this: b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' And I would like to extract the numbers corresponding to S,D,F and M in this string and convert them into an array like this: [ '89.9', '4.4', '1.7', '4.0'] Any he

regex string matching python3

2018-10-01 Thread nanman3012
I have a string like this: b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n' And I would like to extract the numbers corresponding to S,D,F and M in this string and convert them into an array like this: [ '89.9', '4.4', '1.7', '4.0'] Any help would be appreciated! -- https://mail.python

Re: regex pattern to extract repeating groups

2018-08-27 Thread MRAB
On 2018-08-28 00:58, Malcolm wrote: On 28/08/2018 7:09 AM, John Pote wrote: On 26/08/2018 00:55, Malcolm wrote: I am trying to understand why regex is not extracting all of the characters between two delimiters. The complete string is the xmp IFD data extracted from a .CR2 image file. I

Re: regex pattern to extract repeating groups

2018-08-27 Thread Malcolm
On 28/08/2018 7:09 AM, John Pote wrote: On 26/08/2018 00:55, Malcolm wrote: I am trying to understand why regex is not extracting all of the characters between two delimiters. The complete string is the xmp IFD data extracted from a .CR2 image file. I do have a work around, but it's

Re: regex pattern to extract repeating groups

2018-08-27 Thread John Pote
On 26/08/2018 00:55, Malcolm wrote: I am trying to understand why regex is not extracting all of the characters between two delimiters. The complete string is the xmp IFD data extracted from a .CR2 image file. I do have a work around, but it's messy and possibly not future proof. Do you

Re: regex pattern to extract repeating groups

2018-08-27 Thread Rob Gaddi
On 08/25/2018 04:55 PM, Malcolm wrote: I am trying to understand why regex is not extracting all of the characters between two delimiters. The complete string is the xmp IFD data extracted from a .CR2 image file. I do have a work around, but it's messy and possibly not future proof.

regex pattern to extract repeating groups

2018-08-27 Thread Malcolm
I am trying to understand why regex is not extracting all of the characters between two delimiters. The complete string is the xmp IFD data extracted from a .CR2 image file. I do have a work around, but it's messy and possibly not future proof. Any insight greatly appreciated. Malcol

Re: Why this regex for string literals can't handle escaped quotes?.... '"(\\.|[^"])*"'

2018-08-09 Thread cseberino
Wow. Thanks. That cleared everything up. cs -- https://mail.python.org/mailman/listinfo/python-list

Re: Why this regex for string literals can't handle escaped quotes?.... '"(\\.|[^"])*"'

2018-08-09 Thread Peter Otten
cseber...@gmail.com wrote: > Why this regex for string literals > can't handle escaped quotes? '"(\\.|[^"])*"' > > See this... > >>>> string_re = '"(\\.|[^"])*"' > >>>> re.match(string_re, 

Why this regex for string literals can't handle escaped quotes?.... '"(\\.|[^"])*"'

2018-08-09 Thread cseberino
Why this regex for string literals can't handle escaped quotes? '"(\\.|[^"])*"' See this... >>> string_re = '"(\\.|[^"])*"' >>> re.match(string_re, '""') <_sre.SRE_Match object; span=(0, 6),

Re: Better way / regex to extract values form a dictionary

2018-07-22 Thread Thomas Jollans
On 21/07/18 14:39, Ganesh Pal wrote: >> The dictionary is irrelevant to your question. It doesn't matter whether >> the path came from a dict, a list, read directly from stdin, an >> environment variable, extracted from a CSV file, or plucked directly from >> outer space by the programmer. The proc

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Ganesh Pal
> The dictionary is irrelevant to your question. It doesn't matter whether > the path came from a dict, a list, read directly from stdin, an > environment variable, extracted from a CSV file, or plucked directly from > outer space by the programmer. The process remains the same regardless of > wher

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Steven D'Aprano
On Sat, 21 Jul 2018 17:07:04 +0530, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log' > '/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log' > '/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failur

Re: Better way / regex to extract values form a dictionary

2018-07-21 Thread Paul Moore
def return_filename_test_case(filepath): filename = os.path.basename(filepath) testcase = filename.partition('_')[0] return filename, testcase On 21 July 2018 at 12:37, Ganesh Pal wrote: > I have one of the dictionary values in the below format > > '/usr/local/ABCD/EDF/ASASAS/GTH/HELL

Better way / regex to extract values form a dictionary

2018-07-21 Thread Ganesh Pal
I have one of the dictionary values in the below format '/usr/local/ABCD/EDF/ASASAS/GTH/HELLO/MELLO/test04_Failures.log' '/usr/local/ABCD/EDF/GTH/HEL/OOLO/MELLO/test02_Failures.log' '/usr/local/ABCD/EDF/GTH/BEL/LO/MELLO/test03_Failures.log' I need to extract the file name in the path example, say

Re: Regex to extract multiple fields in the same line

2018-06-15 Thread Friedrich Rentsch
17 to 25 in the below code) Here is my code : root@X1:/Play_ground/SPECIAL_TYPES/REGEX# vim Friedrich.py 1 import re 2 from collections import OrderedDict 3 4 keys = ["struct", "loc", "size", "mirror", 5 "filename","

Re: Regex to extract multiple fields in the same line

2018-06-15 Thread Nathan Hilterbrand
ck > /var/1000111/test18.log > 0 > 8 > > > Here is my sample code , its still not complete , I wanted to use regex > and find and extract all the fields after " =", any suggestion or > alternative way to optimize this further > > > import re > line

Re: How can I verify if the regex exist in a file without reading ?

2018-06-15 Thread francois . rabanel
irmation bias, I've been seeing > it everywhere." -- Jon Ronson I resolve my problem and when I look to my solution I don't understand why I didn't do it earlier :) with open(path) as file: result = [] for line in file: find_regex = re.search(regex,line) if find_re

Re: How can I verify if the regex exist in a file without reading ?

2018-06-15 Thread Steven D'Aprano
On Fri, 15 Jun 2018 01:01:03 -0700, francois.rabanel wrote: > I work with a file which contains millions lines, a simply file.read() > and I'm running out of memory Assuming each line is on average a hundred characters long, a million lines is (approximately) 100 MB. Even on a computer with only

Re: Regex to extract multiple fields in the same line

2018-06-15 Thread Ganesh Pal
> >>>> {'struct': 'data_block', 'log_file': '/var/1000111/test18.log', 'loc': > '0', 'size': '8'} > > MARB, as usual the solution you you look nice, Thanks for the excellent solutions

Re: How can I verify if the regex exist in a file without reading ?

2018-06-15 Thread francois . rabanel
Le vendredi 15 juin 2018 02:42:12 UTC+2, Cameron Simpson a écrit : > On 15Jun2018 00:24, Steven D'Aprano > wrote: > >On Fri, 15 Jun 2018 10:00:59 +1000, Cameron Simpson wrote: > >> Francois, unless your regex can cross multiple lines it is better to > >> searc

Re: How can I verify if the regex exist in a file without reading ?

2018-06-14 Thread Cameron Simpson
On 15Jun2018 00:24, Steven D'Aprano wrote: On Fri, 15 Jun 2018 10:00:59 +1000, Cameron Simpson wrote: Francois, unless your regex can cross multiple lines it is better to search files like this: with open(the_filename) as f: for line in f: ... search the line for the r

Re: How can I verify if the regex exist in a file without reading ?

2018-06-14 Thread Steven D'Aprano
On Fri, 15 Jun 2018 10:00:59 +1000, Cameron Simpson wrote: > Francois, unless your regex can cross multiple lines it is better to > search files like this: > > with open(the_filename) as f: > for line in f: > ... search the line for the regexp ... > > That w

Re: How can I verify if the regex exist in a file without reading ?

2018-06-14 Thread Cameron Simpson
e he tried to read the whole file into memory and match against it. Guessing: text = open(the_filename).read() ... search the text for the regexp ... Francois, unless your regex can cross multiple lines it is better to search files like this: with open(the_filename) as f: for

Re: How can I verify if the regex exist in a file without reading ?

2018-06-14 Thread Steven D'Aprano
ith "os.rename" at the end. > > My problem is, if I work on a huge file, I'll try to avoid to read the > file because it will be crash my computer :) How does reading a file crash your computer? > and I would to verify if the regex enter by the user, exist. The only

How can I verify if the regex exist in a file without reading ?

2018-06-14 Thread francois . rabanel
to avoid to read the file because it will be crash my computer :) and I would to verify if the regex enter by the user, exist. I don't know if it's possible, I'm looking for a solution since few hours... so sorry if the question is easy or wtf :) ---

Re: Regex to extract multiple fields in the same line

2018-06-13 Thread Friedrich Rentsch
quot;--size=8" at the end? That's what your explanation implied. How's this? (Supposing that the values contain no spaces): >>> regex = re.compile (r"--(struct|loc|size|mirror|log_file)\s*=\s*([^\s]+)") >>> regex.findall (line) [('struct', 'd

Re: Regex to extract multiple fields in the same line

2018-06-13 Thread MRAB
tion 1: Please let me know the mistakes in the below code and suggest if it can be optimized further with better regex # This code has to extract various the fields from a single line ( assuming the line is matched here ) of a log file that contains various values (and then store the extract

Re: Regex to extract multiple fields in the same line

2018-06-13 Thread Ganesh Pal
and I am able to extract all the required fields , I have 2 further questions too , please suggest Question 1: Please let me know the mistakes in the below code and suggest if it can be optimized further with better regex # This code has to extract various the fields from a single line

Re: Regex to extract multiple fields in the same line

2018-06-13 Thread Rhodri James
On 13/06/18 09:08, Ganesh Pal wrote: Hi Team, I wanted to parse a file and extract few feilds that are present after "=" in a text file . Example , form the below line I need to extract the values present after --struct =, --loc=, --size= and --log_file= Sample input line = '06/12/2018 11

Regex to extract multiple fields in the same line

2018-06-13 Thread Ganesh Pal
me.py --struct=data_block --log_file=/var/1000111/test18.log --addr=None --loc=0 --mirror=10 --path=/tmp/data_block.txt size=8' Expected output data_block /var/1000111/test18.log 0 8 Here is my sample code , its still not complete , I wanted to use regex and find and extract all the fi

Re: I need help with this python regex

2018-04-28 Thread Peter J. Holzer
On 2018-04-27 21:04:49 -0700, Ed Manning wrote: > Here is the source code. > > > import re > > > log = open("csg.txt", "r") # Opens a file call session.txt > regex = re.compile(r'policy id \d+') # search for the policy ID > regex1

I need help with this python regex

2018-04-27 Thread Ed Manning
Here is the source code. import re log = open("csg.txt", "r") # Opens a file call session.txt regex = re.compile(r'policy id \d+') # search for the policy ID regex1 = re.compile(r'log count \d+') # search for the policy ID for match in log: x = reg

Re: Regex for changing :variable to ${variable} in sql query

2018-04-18 Thread zljubisic
On Wednesday, 18 April 2018 19:34:37 UTC+2, MRAB wrote: > > Hi, > > > > I have a sql query in which all variables declared as :variable should be > > changed to ${variable}. > > > > for example this sql: > > > > select * > > from table > > where ":x" = "1" and :y=2 > > and field in (:string)

Re: Regex for changing :variable to ${variable} in sql query

2018-04-18 Thread MRAB
On 2018-04-18 08:25, zljubi...@gmail.com wrote: Hi, I have a sql query in which all variables declared as :variable should be changed to ${variable}. for example this sql: select * from table where ":x" = "1" and :y=2 and field in (:string) and time between :from and :to should be tran

Regex for changing :variable to ${variable} in sql query

2018-04-18 Thread zljubisic
Hi, I have a sql query in which all variables declared as :variable should be changed to ${variable}. for example this sql: select * from table where ":x" = "1" and :y=2 and field in (:string) and time between :from and :to should be translated to: select * from table where "${x}"

RE: Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
-Original Message- From: Python-list On Behalf Of MRAB Sent: Friday, April 13, 2018 12:05 PM To: python-list@python.org Subject: Re: Python regex pattern from array of hex chars > Use re.escape: > > regex = re.compile('[^{}]+'.format(re.escape(''.join

Re: Python regex pattern from array of hex chars

2018-04-13 Thread MRAB
On 2018-04-13 18:28, Joseph L. Casale wrote: I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in c

Python regex pattern from array of hex chars

2018-04-13 Thread Joseph L. Casale
I have an array of hex chars which designate required characters. and one happens to be \x5C or "\". What foo is required to build the pattern to exclude all but: regex = re.compile('[^{}]+'.format(''.join(c for c in character_class))) I would use that in a re.sub t

Re: RegEx to match set of lines

2018-04-05 Thread Terry Reedy
or want to see hundreds of lines. +100 Cut your data down to a SMALL representative sample. Explain how it is coming to you: it looks like you are reading the data in something similar to key:value format. Is that correct? If so, you don't need a regex. This is not Perl, we have more than one

Re: RegEx to match set of lines

2018-04-05 Thread Steven D'Aprano
t your data down to a SMALL representative sample. Explain how it is coming to you: it looks like you are reading the data in something similar to key:value format. Is that correct? If so, you don't need a regex. This is not Perl, we have more than one tool in our toolbox and don't hav

RegEx to match set of lines

2018-04-05 Thread Prahallad Achar
Hello, I would like to match set of lines from the below data. this data comes from one of the network Part of data : [ If circuit type is OCHCC then I need Circuit name and service ID from that group ] Circuit ID: ad8a0165:25 *Circuit Name: T3A_100G_SD20* Circuit Version: 0 Circuit Monitor: fal

Re: Regex Doubts

2018-03-30 Thread Iranna Mathapati
> <<<< > Feature XYZ : 3 valid13 free > > Feature PQR : 0 valid 16 free > > Feature MNO : 0 valid 2 free > > > > """ > > > > i am going to grep MEM values alone and i have

Re: Regex Doubts

2018-03-30 Thread Antoon Pardon
: 0 valid 2 free > > """ > > i am going to grep MEM values alone and i have tried fallowing Regex: > > re.findall(r'MEMR\s+\:\s+([0-9]+)\s+valid \s+([0-9]+)\s+free ', str_output) > > it produce fallowing output:: > [('0&

Re: Regex Doubts

2018-03-30 Thread Cameron Simpson
On 30Mar2018 11:46, Iranna Mathapati wrote: how to achieve fallowing expected output? str_output= """ MOD1 memory : 2 valid1790 free MOD2 memory : 128 valid 128 free UDP Aware *MEMR*: 0 valid 0 free *

Re: Regex Doubts

2018-03-30 Thread Iranna Mathapati
t; MOD2 memory : 128 valid 128 free >> UDP Aware *MEMR*: 0 valid 0 free *MEMR >> : 21 valid 491 free >> <<<<> Feature XYZ : 3 valid13 f

Regex Doubts

2018-03-29 Thread Iranna Mathapati
Hi Team, how to achieve fallowing expected output? str_output= """ MOD1 memory : 2 valid1790 free MOD2 memory : 128 valid 128 free UDP Aware *MEMR*: 0 valid 0 free *MEMR

Re: Regex on a Dictionary

2018-02-15 Thread Andre Müller
Hello, this question also came up there: https://python-forum.io/Thread-Working-with-Dict-Object Greetings Andre -- https://mail.python.org/mailman/listinfo/python-list

Re: Regex on a Dictionary

2018-02-13 Thread Mark Lawrence
On 13/02/18 18:08, Stanley Denman wrote: On Tuesday, February 13, 2018 at 9:41:14 AM UTC-6, Mark Lawrence wrote: On 13/02/18 13:11, Stanley Denman wrote: I am trying to performance a regex on a "string" of text that python isinstance is telling me is a dictionary. When I run the

Re: Regex on a Dictionary

2018-02-13 Thread Stanley Denman
On Tuesday, February 13, 2018 at 9:41:14 AM UTC-6, Mark Lawrence wrote: > On 13/02/18 13:11, Stanley Denman wrote: > > I am trying to performance a regex on a "string" of text that python > > isinstance is telling me is a dictionary. When I run the code I get

Re: Regex on a Dictionary

2018-02-13 Thread Steven D'Aprano
On Tue, 13 Feb 2018 13:53:04 +, Mark Lawrence wrote: > Was the string methods solution that I gave a week or so ago so bad that > you still think that you need a regex to solve this? Sometimes regexes are needed, but often Jamie Zawinski is right: Some people, when confronted

Re: Regex on a Dictionary

2018-02-13 Thread Steven D'Aprano
On Tue, 13 Feb 2018 05:11:20 -0800, Stanley Denman wrote: > I am trying to performance a regex on a "string" of text that python > isinstance is telling me is a dictionary. Please believe Python when it tells you that something is a dictionary. Trust me, the interpreter knows. I

  1   2   3   4   5   6   7   8   9   10   >