|
-
Nov 6th, 2009, 01:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Question about Regular Expression
How do i can put more lines for specific information of regex?
...Regex("(?<=SOMETHING).+?(?=SOMETHING)")
Once again selected from RuneScape, because here is best code for it.
Code:
<tr class="row rowp4">
<td align="center">
<img class="miniimg" src="http://www.runescape.com/img/hiscores/skill_icon_strength1.gif">
</td>
<td class="alL">
<a href="overall.ws?table=3&user=Gertjaars&category_type=0">
Strength
</a>
</td>
<td class="alL">559</td>
<td class="alL">99</td>
<td class="alL">49,065,928</td>
</tr>
Code:
<tr class="row rowp5">
<td align="center">
<img class="miniimg" src="http://www.runescape.com/img/hiscores/skill_icon_hitpoints1.gif">
</td>
<td class="alL">
<a href="overall.ws?table=4&user=Gertjaars&category_type=0">
Hitpoints
</a>
</td>
<td class="alL">3</td>
<td class="alL">99</td>
<td class="alL">181,584,999</td>
</tr>
If you see there is alot of same information. I cannot use <td class="alL"> at one or filters in Regex, because it is everywhere other place too so it pickups random item from there. Only one thing which is different there is: <tr class="row rowp4"> and <tr class="row rowp5">
How do i put it show this?: <td class="alL">99</td>
LOOK: If i put: <tr class="row rowp4"> and </tr> it shows EVERYTHING between of them. So Results are:
<tr class="row rowp5">
Code:
<td align="center">
<img class="miniimg" src="http://www.runescape.com/img/hiscores/skill_icon_hitpoints1.gif">
</td>
<td class="alL">
<a href="overall.ws?table=4&user=Gertjaars&category_type=0">
Hitpoints
</a>
</td>
<td class="alL">3</td>
<td class="alL">99</td>
<td class="alL">181,584,999</td>
</tr>
-
Nov 6th, 2009, 01:36 PM
#2
Hyperactive Member
Re: Question about Regular Expression
RegExp: /<td class="alL">\d\d</td>/g
Match: <td class="alL">99</td> , <td class="alL">99</td>
- because of 'g' (global) switch it will found every instance of it or in this tested string it will produce 2 Matches. Global switch makes multiple matches possible...
RegExp: /<td class="alL">\d\d</td>/
Match: <td class="alL">99</td>
- It will found only first instance of it or in this tested string (1 match).
Tested String:
Code:
<td class="alL">
<a href="overall.ws?table=3&user=Gertjaars&category_type=0">
Strength
</a>
</td>
<td class="alL">559</td>
<td class="alL">99</td>
<td class="alL">49,065,928</td>
</tr>
<tr class="row rowp5">
<td align="center">
<img class="miniimg" src="http://www.runescape.com/img/hiscores/skill_icon_hitpoints1.gif">
</td>
<td class="alL">
<a href="overall.ws?table=4&user=Gertjaars&category_type=0">
Hitpoints
</a>
</td>
<td class="alL">3</td>
<td class="alL">99</td>
<td class="alL">181,584,999</td>
</tr>
-
Nov 6th, 2009, 01:51 PM
#3
Thread Starter
Hyperactive Member
Re: Question about Regular Expression
Man, are you sure it does not show Hitpoints level instead Strength level?
-
Nov 6th, 2009, 03:22 PM
#4
Hyperactive Member
Re: Question about Regular Expression
aha... I did not clearly understand what you wanna from first post.
So basically you wanna extract number 99 from "Strenght paragraph" anywhere on website. Right?
RegEx: Strength\r</a>\r</td>\r<td class="alL">\d+</td>\r<td class="alL">(\d\d)</td>
Inside this regex is 1 capture group ...(\d\d)... and you can retrive it with: $1
Returned result will be: 99
Test String:
Code:
<td class="alL">
<a href="overall.ws?table=3&user=Gertjaars&category_type=0">
Strength
</a>
</td>
<td class="alL">559</td>
<td class="alL">99</td>
<td class="alL">49,065,928</td>
</tr>
<tr class="row rowp5">
<td align="center">
<img class="miniimg" src="http://www.runescape.com/img/hiscores/skill_icon_hitpoints1.gif">
</td>
<td class="alL">
<a href="overall.ws?table=4&user=Gertjaars&category_type=0">
Hitpoints
</a>
</td>
<td class="alL">2</td>
<td class="alL">44</td>
<td class="alL">171,584,999</td>
</tr>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|