Regular expression needed to change the URL while keeping the parameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaushleshsingh
    New Member
    • Feb 2013
    • 1

    Regular expression needed to change the URL while keeping the parameter

    Code:
    <a href="http://localhost/tyrechangr/index.php?option=com_test&task=changsearch.filter_search&srch_brand=1&filter_tb=TB12102012010187,TB12102012010190,TB12102012010186,TB12102012010189,TB12102012010197,TB12102012010199&car_ser=CS1010222725&car_yr=CY101020120056&car_mod=CM101020120148&car_mak=MK101020120006&limitstart=10">ABC </a>
    
    <a href="http://localhost/tyrechangr/index.php?option=com_test&task=changsearch.filter_search&srch_brand=1&filter_tb=TB12102012010187,TB12102012010190,TB12102012010186,TB12102012010189,TB12102012010197,TB12102012010199&car_ser=CS1010222725&car_yr=CY101020120056&car_mod=CM101020120148&car_mak=MK101020120006&limitstart=20">DEF </a>
    
    <a href="http://localhost/tyrechangr/index.php?option=com_test&task=changsearch.filter_search&srch_brand=1&filter_tb=TB12102012010187,TB12102012010190,TB12102012010186,TB12102012010189,TB12102012010197,TB12102012010199&car_ser=CS1010222725&car_yr=CY101020120056&car_mod=CM101020120148&car_mak=MK101020120006&limitstart=30">GHI </a>
    Result required :

    Code:
    <a href="index.php?option=com_test&task=changesearch.tyre_Series_Search&limitstart=10" class="pagenav">ABC</a>
    
    
    <a href="index.php?option=com_test&task=changesearch.tyre_Series_Search&limitstart=20" class="pagenav">DEF</a>
    
    
    <a href="index.php?option=com_test&task=changesearch.tyre_Series_Search&limitstart=30" class="pagenav">GHI</a>
    So What I need I hope its clear from the above but I will still explain you here.

    I want to remove the complete URL as under href keeping limitstart parameter as it is. I am looking for one line regular Expression that can give me the same output as mentioned above in the result.

    Thanks in Advance.

    Using this pattern replaces the complete href value.

    $pattern = '/<a(.*?)href="(. *?)">/';

    but I need to keep &limitstart= val
    Last edited by Rabbit; Feb 4 '13, 05:04 AM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Put the &limitstart in your expression so you know where it is.

    Comment

    Working...