Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

extract string after <SPAN>

Last post 07-08-2008, 7:33 PM by Aussie Susan. 1 replies.
Sort Posts: Previous Next
  •  07-08-2008, 11:24 AM 43889

    extract string after <SPAN>

    i'm think how would i extract the string before SPAN tag. Example

    Hey dude, how's ya<span id="more-10"></span>yo how's life?          =>        Hey dude, how's ya

     

    thanks in advance. 

     

  •  07-08-2008, 7:33 PM 43917 in reply to 43889

    Re: extract string after <SPAN>

    Several alternatives:

    1) use your programming language to locate the the "<span" string and then extract all characters up to but not including the point you have just found

    2) the simple regex answer is:

    ^([^<]*)<span

    and look at match group #1. However, this will also grab any other tags etc. that come before the '<span' text such as "<abc/>text that I want<span id="qwe"></span>" will return "<abc/>text that I want".

    3) using the pattern:

    (?<=>|^)([^<>]*)<span

    which will solve the above issue. It assumes that you are only dealing with a single line (if not, then add "\n" into the character set).

    Susan 

View as RSS news feed in XML