Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regular expression question
#1
i want to match part of a string against a regular expression. normally i would just slice the string and pass that part to re. but my code is not in control of the calls to re methods and only the whole strings are used. the only thing my code gets to control is the pattern. i have a small string of about 10 to 20 characters and i want this to be compared in only the first 80 characters of each string being matched with this pattern. i think i could do this if i needed to skip the first 80 and match the rest. but i need to match the first 80 to this smaller string i put in the pattern, and ignore (.*) everything after 80 (variable amount). there may be strings to match that are shorter than 80 in which the whole string is to be matched. how can i make a regular expression do this?
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
regular expression question - by Skaperen - Aug-20-2021, 12:43 AM
RE: regular expression question - by bowlofred - Aug-20-2021, 03:45 AM
RE: regular expression question - by Skaperen - Aug-21-2021, 05:16 PM
RE: regular expression question - by Gribouillis - Aug-22-2021, 10:05 AM
RE: regular expression question - by Skaperen - Aug-23-2021, 06:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  data validation with specific regular expression shaheen07 0 331 Jan-12-2024, 07:56 AM
Last Post: shaheen07
  Regular Expression search to comment lines of code Gman2233 5 1,663 Sep-08-2022, 06:57 AM
Last Post: ndc85430
  List Creation and Position of Continue Statement In Regular Expression Code new_coder_231013 3 1,662 Jun-15-2022, 12:00 PM
Last Post: new_coder_231013
  Need help with my code (regular expression) shailc 5 1,920 Apr-04-2022, 07:34 PM
Last Post: shailc
  Regular Expression for matching words xinyulon 1 2,167 Mar-09-2022, 10:34 PM
Last Post: snippsat
  How can I find all combinations with a regular expression? AlekseyPython 0 1,672 Jun-23-2021, 04:48 PM
Last Post: AlekseyPython
  Python Regular expression, small sample works but not on file Acernz 5 2,929 Jun-09-2021, 08:27 PM
Last Post: bowlofred
  Regular expression: cannot find 1st number in a string Pavel_47 2 2,414 Jan-15-2021, 04:39 PM
Last Post: bowlofred
  Regular expression: return string, not list Pavel_47 3 2,492 Jan-14-2021, 11:49 AM
Last Post: Pavel_47
  Help with a regular expression t4keheart 2 1,974 Oct-13-2020, 04:05 PM
Last Post: t4keheart

Forum Jump:

User Panel Messages

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