Python Forum
Regex: a string does not starts and ends with the same character
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regex: a string does not starts and ends with the same character
#1
hello. I have a little problem with Python and Regex. In fact, some regex doesn't work if a string does not starts and ends with the same character. For example I have this html tags:

pattern1 = r'<p class="text_obisnuit">.*((bebe|oana|mother|sun).*){3,}.*</p>'
pattern2 = r'<p class="text_obisnuit2">.*((bebe|oana|mother|sun).*){3,}.*</p>'
pattern3 = r'<title>.*((bebe|oana|mother|sun).*){3,}.*</title>'
pattern4 = r'<meta name="description" content=.*((bebe|oana|mother|sun).*){3,}.*>'
The first 3 tags are working, because a string is starts and ends with the same character.

But the 4 tag, the one with meta description, is not working. Python cannot find anything with the regex.
Reply


Messages In This Thread
Regex: a string does not starts and ends with the same character - by Melcu54 - Jul-03-2021, 08:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Move column to the right if it starts with a letter mfernandes 0 694 Oct-25-2022, 11:22 AM
Last Post: mfernandes
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,415 Sep-27-2022, 01:38 PM
Last Post: buran
  pywin32: Outlook connection ends with 'operation aborted' on one machine tstone 0 2,442 May-03-2022, 04:29 AM
Last Post: tstone
  Setup Portable Python on Windows for script starts with double clicks? pstein 0 1,844 Feb-18-2022, 01:29 PM
Last Post: pstein
  [solved] unexpected character after line continuation character paul18fr 4 3,470 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  threadlocals are garbage collected before thread ends akv1597 0 1,824 Mar-09-2021, 12:13 PM
Last Post: akv1597
  Running a few lines of code as soon as my timer ends nethatar 3 2,446 Feb-26-2021, 01:02 PM
Last Post: jefsummers
  '|' character within Regex returns a tuple? pprod 10 5,651 Feb-19-2021, 05:29 PM
Last Post: eddywinch82
  Writing to file ends incorrectly project_science 4 2,735 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Help getting a string out of regex matt_the_hall 4 2,305 Dec-02-2020, 01:49 AM
Last Post: matt_the_hall

Forum Jump:

User Panel Messages

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