Results 1 to 2 of 2

Thread: Regex of formatted text?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Regex of formatted text?

    The text I am trying to put my pattern into is:


    Code:
    		<li class="hp">
    			<span>HP</span>
    			<strong>1850 (+300)</strong>
    		</li>
    thats the format...

    The (+300) can go away...i'd really only like to return just the 1850.

    How would I do that in code?

    with the multiple lines like that?

  2. #2
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: Regex of formatted text?

    This should do it:
    Code:
    chr(9) & chr(9) & "<li class=""hp"">" & chr(13) & chr(10) & chr(9) & chr(9) & chr(9) & "<span>HP</span>" & chr(13) & chr(10) & chr(9) & chr(9) & chr(9) & "<strong>([^( ]+)"
    Code:
    Try
    	Debug.Print(Regex.Match(strText, chr(9) & chr(9) & "<li class=""hp"">" & chr(13) & chr(10) & chr(9) & chr(9) & chr(9) & "<span>HP</span>" & chr(13) & chr(10) & chr(9) & chr(9) & chr(9) & "<strong>([^( ]+)").Groups(1).Value)
    Catch ex As ArgumentException
    	'Syntax error in the regular expression
    End Try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width