Results 1 to 4 of 4

Thread: [RESOLVED] Question about Regular Expression

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Resolved [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&amp;user=Gertjaars&amp;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&amp;user=Gertjaars&amp;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&amp;user=Gertjaars&amp;category_type=0">
    
    Hitpoints
    </a>
    </td>
    <td class="alL">3</td>
    <td class="alL">99</td>
    <td class="alL">181,584,999</td>
    </tr>

  2. #2
    Hyperactive Member Zeljko's Avatar
    Join Date
    Oct 2006
    Location
    Internet
    Posts
    441

    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&amp;user=Gertjaars&amp;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&amp;user=Gertjaars&amp;category_type=0">
    
    Hitpoints
    </a>
    </td>
    <td class="alL">3</td>
    <td class="alL">99</td>
    <td class="alL">181,584,999</td>
    </tr>
    1. If this post helped you, please Rate it = That's You, saying Thanks, to Me ...Left side of this post: [Rate this post]
    2. Mark this Thread Resolved if your question has been answered That's You, saying Thanks, to Group ...Menu on top of your original Post: [Thread Tools]>[Mark Thread Resolved]
    3.
    Check my site: www.er-ef.netCheck my snippets: Get installed .NET versionsRegex extractingJoin hierarchically nested Datatables in one flattened Datatable


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2008
    Location
    >> ( ҉ )
    Posts
    413

    Re: Question about Regular Expression

    Man, are you sure it does not show Hitpoints level instead Strength level?

  4. #4
    Hyperactive Member Zeljko's Avatar
    Join Date
    Oct 2006
    Location
    Internet
    Posts
    441

    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&amp;user=Gertjaars&amp;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&amp;user=Gertjaars&amp;category_type=0">
    
    Hitpoints
    </a>
    </td>
    <td class="alL">2</td>
    <td class="alL">44</td>
    <td class="alL">171,584,999</td>
    </tr>
    1. If this post helped you, please Rate it = That's You, saying Thanks, to Me ...Left side of this post: [Rate this post]
    2. Mark this Thread Resolved if your question has been answered That's You, saying Thanks, to Group ...Menu on top of your original Post: [Thread Tools]>[Mark Thread Resolved]
    3.
    Check my site: www.er-ef.netCheck my snippets: Get installed .NET versionsRegex extractingJoin hierarchically nested Datatables in one flattened Datatable


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