Python Forum
wanted: regex or code to find valide def statements in a line
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wanted: regex or code to find valide def statements in a line
#5
(Mar-14-2020, 01:20 PM)Skaperen Wrote: i didn't have anything to try. and these sample regexes don't look like they are anywhere close to checking the whole line for validity
Need to have input to test on,or make some input as i done then can also try to make as difficult as possible to see how the regex work for many cases.

(Mar-14-2020, 01:20 PM)Skaperen Wrote: perhaps works OK on valid lines, but can it report all possible invalid lines as invalid?
The would be all lines that the regex don't match.
>>> def_line
['def my_game():', 'def foo(arg):', 'def Bar(args*, kwargs**):']
>>> 
>>> for line in text.split('\n'):
...     if line not in def_line:     
...         print(line)
...         
    print('Game running')

def 123

    pass

    pass

hello def is nice
def () wrong
Reply


Messages In This Thread
RE: wanted: regex or code to find valide def statements in a line - by snippsat - Mar-14-2020, 02:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python code wanted: grep IP address Skaperen 7 6,166 Jul-09-2018, 05:25 AM
Last Post: Skaperen
  code wanted, but don't expect me to do it Skaperen 0 2,103 Jul-07-2018, 10:50 PM
Last Post: Skaperen
  command line progam wanted: clock Skaperen 2 2,722 Apr-18-2018, 06:54 AM
Last Post: Gribouillis
  code wanted: file splicing Skaperen 10 6,482 Mar-28-2018, 12:13 AM
Last Post: Skaperen
  looking 4 py code: line up columns Skaperen 8 7,874 Jan-09-2017, 05:15 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020