Regex.Matcher woes...

ChrShe

Member
Licensed User
Longtime User
Good day,
Given the following input:
B4X:
<div class="list-animal-name"><a href="wsAdoptableAnimalDetails.aspx?id=13069119&css=adoptableSearch.css" >Jed</a></div>

I've tried using variations of:
B4X:
Regex.Matcher("class=\""list-animal-name\"">([^>]+)", page)

However, that seems to be hacing off the end of the line, just before ">Jed".
One thing, about the input line, is that the number following "id=" is never the same twice.

So, how can I use the matcher to grab just "Jed" from the above line?

THANKS in advance!
~Chris :BangHead:
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim s As String = "<div class=""list-animal-name""><a href=""wsAdoptableAnimalDetails.aspx?id=13069119&css=adoptableSearch.css"" >Jed</a></div>"
   Dim m As Matcher = Regex.Matcher("class=\""([^""]+)\""><[^>]+>([^>]+)</a>", s)
   Do While m.Find
      Log(m.Group(2))
   Loop
End Sub
 
Upvote 0

ChrShe

Member
Licensed User
Longtime User
Thank you very much!!!

Is there a page that describes what all the bits in the pattern mean?

How do I know if I need "/[+)" or "([^>+)"?

Thanks again!!!!
~Chris
Sent from my MOTO DROID RAZR using Tapatalk.
 
Upvote 0

hyokim07

Member
Licensed User
Longtime User
Hi, Erel!
I am trying to download image from the web with the following input:
<div class="img"><img id="imgid48" src="image/Kim_Hyo.jpg" alt="Kim_Hyo" width="220" height="220" onClick="toggleIt('id48a')"><div class="desc" id="name48">Kim Hyo</div><div class="desc" id="id48a">?</div></div>

I am trying to use Regex.Matcher. I am lost. Can you please help me?
Thank you very much in advance.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…