Python Forum
re module: want a regexhttps://python-forum.io/Thread-re-module-want-a-regex
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
re module: want a regexhttps://python-forum.io/Thread-re-module-want-a-regex
#1
a script i am working on will get a list of parameters to parse into parts. i am hoping re can do this for me but i am clueless how to make an appropriate regex. i can barely filter out .py files from a list of files.

each parameter is 3 decimal numbers each preceded with one of the characters "/" "@" or "+". the character in front identifies which number it is. for example, the number that follows "@" is the workspace number. for each parameter i need to get the 3 numbers (as 3 strings) identified with which character in front. for example i need to get the same results for "@1/2+3", "/2@1+3", "@1+3/2", "+3@1/2", "/2+3@1", and "+3/2@1". so it's more than just matching the pattern. it' associating various parts together in the right order. i think the match has to have a way to give a choice of any of the 3, each expressed with its leading character and which index it goes to, and do exactly 3 of them. but i don't know how to express this or how to be sure "@1@2/3" does not match (because "+" is missing). regex is a whole other language, harder than even lisp.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
re module: want a regexhttps://python-forum.io/Thread-re-module-want-a-regex - by Skaperen - Sep-14-2019, 03:51 AM
RE: re module: want a regex - by Gribouillis - Sep-14-2019, 08:24 AM
RE: re module: want a regex - by Skaperen - Sep-14-2019, 07:48 PM
RE: re module: want a regex - by ndc85430 - Sep-14-2019, 07:54 PM
RE: re module: want a regex ... - by Skaperen - Sep-19-2019, 10:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  importing a module given a path to the file Skaperen 8 1,304 Nov-04-2023, 07:03 PM
Last Post: Skaperen
  where module is loaded from Skaperen 1 730 Jul-26-2023, 05:38 AM
Last Post: Gribouillis
  looking fo documentation for module files Skaperen 39 90,170 Aug-09-2022, 07:37 AM
Last Post: Gribouillis
  Mixed types of numeric data in the statistics module stevendaprano 2 1,301 May-23-2022, 02:15 AM
Last Post: stevendaprano
  a module can be found but another cannot Skaperen 7 2,686 Oct-25-2021, 12:16 AM
Last Post: Skaperen
  Eric6 No module named 'serial' BvdP4Py 0 2,709 Jul-30-2021, 08:38 AM
Last Post: BvdP4Py
Lightbulb Feedback needed! Controlled entropy in programs with 'ordered' module grandrew 0 1,409 Jul-27-2021, 01:49 AM
Last Post: grandrew
  PIL module and Python 2.7 under Windows 10 Lad 3 2,151 Jul-06-2021, 07:39 PM
Last Post: Lad
  visual studio code python how to get source code of import module definitian umen 2 3,926 Jun-13-2020, 06:20 PM
Last Post: umen
  finding a mismatched triple-quote in a huge module Skaperen 1 1,576 Apr-15-2020, 04:29 AM
Last Post: UGuntupalli

Forum Jump:

User Panel Messages

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