#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Regex to match multiline but same pattern in python


    So python regex allows you to name your auto variables. nice!

    But here is the problem

    <ProductName>(?P<product_sku1>\w+)</ProductName>
    <ProductName>(?P<product_sku2>\w+)</ProductName>
    <ProductName>(?P<product_sku3>\w+)</ProductName>
    <ProductName>(?P<product_sku4>\w+)</ProductName>

    I have an xml file that looks like this. The problem is that ProductName elements can be 0 or more. How do i match all occurrences and push the value into a named variable?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    35
    Rep Power
    3
    I think it's not possible.
    You will have to search for all matches and iterate over them.

    _____________
    Visit my project: Derivative Calculator

IMN logo majestic logo threadwatch logo seochat tools logo