SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wanted: Regex tutorials

    I'd much like to learn regexp, and I am starting to get some of it, but finding a tutorial that explains things concisely is difficult to do. I have a specific purpose in mind, but I'd rather not have someone do my work for me. ANy recommendations for good tutorials on regexp?

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This book:

    Mastering Regular Expressions, 3rd Edition
    by Jeffrey E. F. Friedl
    Publisher: O'Reilly
    Pub Date: August 8, 2006
    Print ISBN-10: 0-596-52812-4
    Print ISBN-13: 978-0-596-52812-6


    Highly recommended.

    Also, download the free Expresso tool for playing/experimenting and testing regexes.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion. I've got a regexp that I thought would do what I need, but it's not working, and perhaps you can help.

    Code:
    [.*?]?<(title*)\b[^>]*>(.*?)</\1>[.*?]?"body"\s*-->([.*?]?)<-- InstanceEndEditable -->[.*?]?
    It's supposed to capture the text inside the title tags (this part actually works) and everything in the "body" ('"body" -->' is part of a comment tag), and then captures everything between that and it's closing accompaniment <-- InsanceEndEditable -->, and wraps up by grabbing whatever else is left. This is supposed to strip out just the title text and whatever's in the body of a document, while everything else is grabbed so it can be replaced.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •