Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:54:19+00:00 2026-06-12T08:54:19+00:00

Simple one here but I’m fairly new to Python. I have a string like

  • 0

Simple one here but I’m fairly new to Python.

I have a string like this:

this is page one of an article 
<!--pagebreak page two --> this is page two 
<!--pagebreak--> this is the third page 
<!--pagebreak page four --> last page
// newlines added for readability

I need to split the string using this regex: <!--pagebreak(*.?)--> – the idea is that sometimes the <!--pagebreak--> comments have a ‘title’ (which I use in my templates), other times they don’t.

I tried this:

re.split("<!--pagebreak*.?-->", str)

which returned only the items with ‘titles’ in the pagebreak (and didn’t split them correctly either). What am I doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:54:22+00:00Added an answer on June 12, 2026 at 8:54 am

    Change *.? into .*?:

    re.split("<!--pagebreak.*?-->", str)
    

    Your current regex accepts any number of literal k‘s, optionally followed by (any character).

    Also, I would recommend using raw strings (r"...") for your regular expressions. It’s not necessary in this case, but it’s an easy way to spare yourself a few headaches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a feeling I'm missing something pretty simple here but, in this one
This is probably a simple one to answer, but I'm stuck, so here goes.
This is two questions in one, so here we go. I have a simple
Simple one here, i once knew this but it has been lost over the
This might be a simple one but here goes: I'm implementing an excel downloadable
Apologies if this is a bit of a simple one, but I'm quite new
The request is a simple one, but is hard to google for. Here are
This should be a simple one: I have an observableArray object called To in
This should be a simple one and I am dissapointed with myself but cant
This should be a simple one, basically I have a few paths drawn with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.