Problem with Regex and Matcher

Mark Read

Well-Known Member
Licensed User
Longtime User
I have a text line read from a HTML page, example:

B4X:
line="<p><a href="thumbs/leralyn-1-7892.jpg"><img alt="" src="thumbs/leralyn-1.jpg" border="2" height="284" width="200"></a><br>"

I want to extract the filename and have been using the FlickrViewer as basic code. I have only made a few minor changes to the HandleMainPage sub.

My catch pattern is as follow:

B4X:
pattern="<a href=qthumbs/\w+\.jpgq".Replace("q", QUOTE)   '<a href="thumbs/somename.jpg">

The regex command should pull out the filename as commented in pattern above.

B4X:
m = Regex.Matcher(pattern, line)

The problem is that it doesn't work, my pattern is wrong.

I have traced the problem to the "-" in the filename but I cannot change this, the files are on a public server. Using a workaround I replaced the "-" with a "_" and then everything works.

Does anyone have a better mask for the pattern variable?

Thanks, Mark
 

Mark Read

Well-Known Member
Licensed User
Longtime User
@Erel

If only life was as simple as your answers. Thanks, works a dream.

:sign0142:
 
Upvote 0
Top