Pattern matching [newbie]

Discussion in 'Perl Misc' started by vivek_12315, Feb 13, 2013.

  1. vivek_12315

    vivek_12315 Guest

    I m working on my perl regex code, where I have to parse a html line like :

    <a href="/question?id=15422849"><p>MY text here 1</p><p>MY text here 2</p><p>MY text here 3</p></a>

    I am doing something like:
    $string =~ m/(.*)href(.*)/;

    But this is not helping me in what I want. I want something closer to following text:

    "MY text here 1 MY text here 2 MY text here 3"

    Can some give some ideas ?
    vivek_12315, Feb 13, 2013
    1. Advertisements

  2. Your Question used to be Asked Frequently. Please see

    perldoc -q "remove html"

    Jürgen Exner, Feb 13, 2013
    1. Advertisements

  3. vivek_12315

    brian d foy Guest
    brian d foy, Feb 13, 2013
  4. Actually for this particular example it is almost trivial(*):
    Of course this is going to fail as soon as the HTML code becomes a tiny
    bit more complex.

    *: almost because it doesn't add the space characters between the
    individual paragraph elements.

    Jürgen Exner, Feb 13, 2013
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.