使用正则表达式替换第二次出现的子字符串

I have a string with xml formatted like what is shown below.

How can I find the second occurrence of <para> and replace with <para align='left'>?

$str = "<para>From the New York Times</para>

<para>Instacart, a two-year-old grocery delivery company, announced a $44 million round of financing on Monday led by Andreessen Horowitz. Three venture capital firms that previously invested in the company, Sequoia Capital, Khosla Ventures and Canaan Partners, participated in the latest round.</para>

<para>The company, which is based in San Francisco, lets customers shop online from grocery stores in their area. The orders are filled by other people who have signed up to be shoppers and who receive a cut of the delivery fees. Information about a store’s inventory comes from store managers and from the shoppers. The company says it can have groceries delivered within an hour.</para>";
查看全部
drsvw88664
drsvw88664
2014/06/16 17:02
  • regex
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复