Python Forum
Matching multiple parts in string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matching multiple parts in string
#2
1 Astring and Bstring aren't strings, they're lists. Is there a reason you have the brackets around them? Does the findall() call generate an error about passing in an unhashable type?
2 The re module uses regular expressions, not globs. The initial * in Bstring isn't legal and the dots will match anything.
3 re.findall takes a pattern and a string to match. You're passing them in backward.

Changing those things:

>>> a = '123.456.789.10.11.12.abc'
>>> b = '.*.456.789.*.11.12.*'
>>> re.findall(b,a)
['123.456.789.10.11.12.abc']
Reply


Messages In This Thread
Matching multiple parts in string - by fozz - Apr-26-2022, 02:48 PM
RE: Matching multiple parts in string - by bowlofred - Apr-26-2022, 03:35 PM
RE: Matching multiple parts in string - by fozz - Apr-26-2022, 09:59 PM
RE: Matching multiple parts in string - by fozz - Apr-29-2022, 10:26 PM
RE: Matching multiple parts in string - by fozz - May-01-2022, 03:56 AM
RE: Matching multiple parts in string - by fozz - May-05-2022, 09:52 AM
RE: Matching multiple parts in string - by fozz - May-06-2022, 03:25 PM
RE: Matching multiple parts in string - by fozz - May-06-2022, 11:01 PM
RE: Matching multiple parts in string - by fozz - Jun-04-2022, 08:31 PM
RE: Matching multiple parts in string - by fozz - Jun-07-2022, 12:09 PM
RE: Matching multiple parts in string - by DeaD_EyE - Jun-07-2022, 01:15 PM
RE: Matching multiple parts in string - by fozz - Jun-07-2022, 04:04 PM
RE: Matching multiple parts in string - by fozz - Jun-07-2022, 05:26 PM
RE: Matching multiple parts in string - by fozz - Jun-07-2022, 11:42 PM
RE: Matching multiple parts in string - by DeaD_EyE - Jun-08-2022, 02:40 PM
RE: Matching multiple parts in string - by fozz - Jun-08-2022, 11:55 PM
RE: Matching multiple parts in string - by DeaD_EyE - Jun-09-2022, 09:51 AM
RE: Matching multiple parts in string - by fozz - Jun-09-2022, 10:17 PM
RE: Matching multiple parts in string - by DeaD_EyE - Jun-10-2022, 12:29 PM
RE: Matching multiple parts in string - by fozz - Jun-12-2022, 12:10 AM
RE: Matching multiple parts in string - by fozz - Jun-12-2022, 01:27 PM
RE: Matching multiple parts in string - by DeaD_EyE - Jun-12-2022, 04:21 PM
RE: Matching multiple parts in string - by fozz - Jun-13-2022, 09:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Matching string from a file tester_V 5 549 Mar-05-2024, 05:46 AM
Last Post: Danishhafeez
  splitting file into multiple files by searching for string AlphaInc 2 1,000 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  Save multiple Parts of Bytearray to File ? lastyle 1 999 Dec-10-2022, 08:09 AM
Last Post: Gribouillis
  matching a repeating string Skaperen 2 1,324 Jun-23-2022, 10:34 PM
Last Post: Skaperen
  Extract parts of multiple log-files and put it in a dataframe hasiro 4 2,177 Apr-27-2022, 12:44 PM
Last Post: hasiro
  Search multiple CSV files for a string or strings cubangt 7 8,312 Feb-23-2022, 12:53 AM
Last Post: Pedroski55
  Matching Exact String(s) Extra 4 2,015 Jan-12-2022, 04:06 PM
Last Post: Extra
  Replace String in multiple text-files [SOLVED] AlphaInc 5 8,318 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
Question How to extract multiple text from a string? chatguy 2 2,455 Feb-28-2021, 07:39 AM
Last Post: bowlofred
  How to print string multiple times on new line ace19887 7 5,904 Sep-30-2020, 02:53 PM
Last Post: buran

Forum Jump:

User Panel Messages

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