Results 1 to 4 of 4

Thread: Bit of regex

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    26

    Bit of regex

    This is my second post in this thread... The first one I made I got accused of writing a hack. Id just like to start off saying that this is no such thing. If you would look at my code instead of just assuming you could see that.

    Anyhoo. This is a small sub routine for my bot. The deal is when a player dies in the game a bounty number is displayed at the end of there name. The bounty number is always between brackets "(402)" And can be anywhere from (0) to (30000).

    Now the issue is that i need to remove this number from there name so the bot can reply to them. Here is the code I came up with using regex.

    Killed(0) is the person who got the kill
    m is match. (each match in string)
    Then item_index route is adding the name to a list for further processing.

    Code:
     t = killed(0)
          re.Pattern = "\(*\d\d*\)$"
          re.Global = True
          For Each m In re.Execute(t)
          killed2 = Split(killed(0), m.Value)
          item_index = SendMessage2(List1.hwnd, LB_FINDSTRING, -1, killed2(0))
             Next
    What I was thinking could be done is some reverse parsing. Since the bounty is displayed at the end of a name and is always encapsulated in ()'s if there was some way to find the first ( from right to left in a string that would work

    Ah and on a side note the players name May or may not contain brackets.
    Last edited by Alvanian; Dec 10th, 2007 at 05:24 PM.

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